generic method
use to validate generic fields
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: (value) => Mask.validations.generic(
value,
error: 'your message error', // optional field
min: 8, // optional field
),
),
------------ or ------------
TextFormField(
autovalidateMode: AutovalidateMode.onUserInteraction,
validator: Mask.validations.generic,
),
Implementation
String? generic(
String? value, {
String error = 'Campo inválido',
int min = 1,
}) {
if ((value ?? "").trim().length < min) return error;
return null;
}