listIsOfLength function
Validates that the list's length is the same as the provided size
This validator also validates that the value is a list first
So there's no need to add the isTypeList
validator when using this validator
Implementation
Validator listIsOfLength(int size) {
return (value) {
final isListResult = isType<List>().call(value);
if (isListResult.isNotValid) return isListResult;
return Result(
isValid: (value as List).length == size,
expected: 'List of size $size',
value: value,
);
};
}