DBStoneValidators

Objective-C

@interface DBStoneValidators<T> : NSObject

Swift

class DBStoneValidators<T> : NSObject where T : AnyObject

Validator functions used by SDK to impose value constraints.

  • Validator for NSString objects. Enforces minimum length and/or maximum length and/or regex pattern.

    Declaration

    Objective-C

    + (void (^_Nonnull)(NSString *_Nonnull))
        stringValidator:(nullable NSNumber *)minLength
              maxLength:(nullable NSNumber *)maxLength
                pattern:(nullable NSString *)pattern;

    Swift

    class func stringValidator(_ minLength: NSNumber?, maxLength: NSNumber?, pattern: String?) -> (String) -> Void
  • Validator for NSNumber objects. Enforces minimum value and/or maximum value.

    Declaration

    Objective-C

    + (void (^_Nonnull)(NSNumber *_Nonnull))
        numericValidator:(nullable NSNumber *)minValue
                maxValue:(nullable NSNumber *)maxValue;

    Swift

    class func numericValidator(_ minValue: NSNumber?, maxValue: NSNumber?) -> (NSNumber) -> Void
  • Validator for NSArray objects. Enforces minimum number of items and/or maximum minimum number of items. Method requires a validator block that can validate each item in the array.

    Declaration

    Objective-C

    + (void (^_Nonnull)(NSArray<T> *_Nonnull))
        arrayValidator:(nullable NSNumber *)minItems
              maxItems:(nullable NSNumber *)maxItems
         itemValidator:(void (^_Nullable)(T _Nonnull))itemValidator;

    Swift

    class func arrayValidator(_ minItems: NSNumber?, maxItems: NSNumber?, itemValidator: ((T) -> Void)? = nil) -> ([T]) -> Void
  • Validator for NSDictionary objects. Enforces minimum number of items and/or maximum minimum number of items. Method requires a validator block that can validate each item in the array.

    Declaration

    Objective-C

    + (void (^_Nonnull)(NSDictionary<NSString *, T> *_Nonnull))mapValidator:
        (void (^_Nullable)(T _Nonnull))itemValidator;

    Swift

    class func mapValidator(_ itemValidator: ((T) -> Void)? = nil) -> ([String : T]) -> Void
  • Wrapper validator for nullable objects. Maintains a reference to the object’s normal non-nullable validator.

    Declaration

    Objective-C

    + (void (^_Nonnull)(T _Nonnull))nullableValidator:
        (void (^_Nonnull)(T _Nonnull))internalValidator;

    Swift

    class func nullableValidator(_ internalValidator: @escaping (T) -> Void) -> (T) -> Void