requiredField static method

ValidatorEvent requiredField()

Validator to check if a field is required (non-null and non-empty).

Implementation

static ValidatorEvent requiredField() => (value) {
      var res = (value != null && value.toString().trim().isNotEmpty);
      return FieldValidateResult(
        success: res,
        error: res ? '' : 'error.field.required',
      );
    };