requiredValidator<TEntity> function
ValidatorsFunction<FormControl<TEntity> >
requiredValidator<TEntity>({
- String message = 'Поле обязательно',
- dynamic eventType = ValidationEventTypes.Error,
Implementation
ValidatorsFunction<FormControl<TEntity>> requiredValidator<TEntity>(
{String message = 'Поле обязательно',
eventType = ValidationEventTypes.Error}) =>
(FormControl<TEntity> control) async {
if (control.value == null ||
(TEntity == String && (control.value as String).isEmpty == true)) {
return [
ValidationEvent(
key: requiredValidatorKey,
message: message,
type: eventType,
)
];
}
return [];
};