validate method

String? validate()

Implementation

String? validate() {
  if (hasError) {
    return error;
  }
  if (isRequired && isNull) {
    return "Field $name is required";
  }
  return null;
}