MBAttributeValidator Class Reference
| Inherits from | NSObject |
|---|---|
| Declared in | MBAttributeValidator.h |
Overview
MBAttributeValidator instances can be used to verify that a given
MBDataModel contains an expected set of values.
+ validatorForDataModel:
Returns a new MBAttributeValidator to be used for validating the specified
MBDataModel.
+ (nonnull instancetype)validatorForDataModel:(nonnull MBDataModel *)modelParameters
model |
The |
|---|
Declared In
MBAttributeValidator.h
model
Returns the MBDataModel that the receiver was constructed to validate.
@property (nonnull, nonatomic, readonly) MBDataModel *modelDeclared In
MBAttributeValidator.h
validationErrorMessages
Returns an array of NSStrings containing error messages for any problems
encountered during validation. Will be nil if no validation errors
have occurred.
@property (nullable, nonatomic, readonly) NSArray *validationErrorMessagesDeclared In
MBAttributeValidator.h
– require:or:
Requires that the data model contain either attr1 or attr2 but not
both.
- (BOOL)require:(nonnull NSString *)attr1 or:(nonnull NSString *)attr2Parameters
attr1 |
The name of the first attribute. |
|---|---|
attr2 |
The name of the second attribute. |
Return Value
YES if the validation requirement was satisfied; NO otherwise.
Declared In
MBAttributeValidator.h
– require:or:butNotBoth:
Requires that the data model contain either attr1 or attr2.
- (BOOL)require:(nonnull NSString *)attr1 or:(nonnull NSString *)attr2 butNotBoth:(BOOL)onlyAllowOneParameters
attr1 |
The name of the first attribute. |
|---|---|
attr2 |
The name of the second attribute. |
onlyAllowOne |
If |
Return Value
YES if the validation requirement was satisfied; NO otherwise.
Declared In
MBAttributeValidator.h
– requireAtLeastOneOf:
Requires at least one of a set of attribute names to be present in the data model. Validation will fail if none of the specified attributes are present.
- (BOOL)requireAtLeastOneOf:(nonnull NSObject<NSFastEnumeration> *)attrsParameters
attrs |
An enumeration of |
|---|
Return Value
YES if the validation requirement was satisfied; NO otherwise.
Declared In
MBAttributeValidator.h
– requireExactlyOneOf:
Requires exactly one of a set of attribute names to be present in the data model. Validation will fail if none of the specified attributes are present, or if more than one is present.
- (BOOL)requireExactlyOneOf:(nonnull NSObject<NSFastEnumeration> *)attrsParameters
attrs |
An enumeration of |
|---|
Return Value
YES if the validation requirement was satisfied; NO otherwise.
Declared In
MBAttributeValidator.h
– validate
Returns YES if all validation requirements were satisfied.
- (BOOL)validateReturn Value
YES if validation succeeded; NO otherwise.
Discussion
If validation did not succeed, the error messages contained in
validationErrorMessages will be logged to the console.
Declared In
MBAttributeValidator.h