getCheckboxValidator method

CheckboxValidationFunction getCheckboxValidator(
  1. Map spec
)

Convenience method returning a generic validator for bool input Widgets.

Implementation

CheckboxValidationFunction getCheckboxValidator(Map spec) {
  var required = parseBool(spec["required"]);
  var requiredText = Lowder.properties.getText(
      spec["requiredMessage"] ?? "required_field_message", "errorMessage");

  return (value) {
    if (required && (value == null || !value)) {
      return requiredText;
    }
    return null;
  };
}