length function

IEskValidator length(
  1. List<IEskValidator> validators
)

Checks whether the given value has a length property and the length matches the validators

Implementation

IEskValidator length(List<IEskValidator> validators) => EskValidator((value) {
      if (hasLengthProperty(value)) {
        final result = all(validators).validate((value as dynamic).length);
        return result.copyWith(
          error: 'length ${result.error}',
        );
      } else {
        return EskResult.invalid(
          '${value.runtimeType} does not have a length property',
          value,
        );
      }
    });