generic method

String? generic(
  1. String? value, {
  2. String error = 'Campo inválido',
  3. int min = 1,
})

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;
}