fromDynamic static method

MaxLengthValidator fromDynamic(
  1. dynamic map
)

Processes the validator object from the given map which must be an actual Map or a Map-like object that supports the [] operator. Any non-null object that is not Map-like will result in an error. A null value will result in a return value of null.

This expects the JSON format:

{
  "length": <number>,
  "type": "max_length"
}

Implementation

static MaxLengthValidator fromDynamic(dynamic map) {
  MaxLengthValidator result;

  if (map == null) {
    throw Exception('[MaxLengthValidator.fromDynamic]: map is null');
  } else {
    assert(map['type'] == kType);

    result = MaxLengthValidator(
      length: JsonClass.maybeParseInt(
            map['length'],
          ) ??
          0,
    );
  }

  return result;
}