Validate.length constructor Null safety

const Validate.length(
  1. {int? lessThan,
  2. int? greaterThan,
  3. int? equalTo,
  4. int? greaterThanEqualTo,
  5. int? lessThanEqualTo,
  6. bool onUpdate = true,
  7. bool onInsert = true}
)

A validator for validating the length of a String.

Values passing through validators of this type must a String with a length that islessThan, greaterThan, lessThanEqualTo, equalTo, or [greaterThanEqualTo to the value provided for each argument.

Any argument not specified is not evaluated. A typical validator only uses one argument:

    @Validate.length(lessThan: 10)
    String foo;

All provided arguments are evaluated. Therefore, the following requires an input string to have a length to be between 6 and 10:

    @Validate.length(greaterThanEqualTo: 6, lessThanEqualTo: 10)
    String foo;

If onUpdate is true (the default), this validation is run on update queries. If onInsert is true (the default), this validation is run on insert queries.

Implementation

const Validate.length(
    {int? lessThan,
    int? greaterThan,
    int? equalTo,
    int? greaterThanEqualTo,
    int? lessThanEqualTo,
    bool onUpdate = true,
    bool onInsert = true})
    : this._(
          lessThan: lessThan,
          lessThanEqualTo: lessThanEqualTo,
          greaterThan: greaterThan,
          greaterThanEqualTo: greaterThanEqualTo,
          equalTo: equalTo,
          onUpdate: onUpdate,
          onInsert: onInsert,
          validator: ValidateType.length);