diff --git a/glade_forms/CHANGELOG.md b/glade_forms/CHANGELOG.md index 861bba3..43e6a6f 100644 --- a/glade_forms/CHANGELOG.md +++ b/glade_forms/CHANGELOG.md @@ -1,4 +1,5 @@ ## DEV: +- **[Add]**: Add `allowBlank` parameter to `isEmpty` string validator. - **[Add]**: Add `IntInput` as a specialized variant of GladeInput which has additional, int related, validations such as `isBetween`, `isMin`, `isMax` - **[Add]**: Support skipping particular validation with `shouldValidate` callback. - **[Breaking]**: The `resetToPure` method on both GladeInput and GladeModel has been renamed to `setAsNewPure`. This change better reflects the method's behavior of setting a new pure state rather than resetting to the original state. diff --git a/glade_forms/lib/src/validator/string_validator.dart b/glade_forms/lib/src/validator/string_validator.dart index 426a1ba..63286a4 100644 --- a/glade_forms/lib/src/validator/string_validator.dart +++ b/glade_forms/lib/src/validator/string_validator.dart @@ -9,9 +9,10 @@ class StringValidator extends GladeValidator { OnValidateError? devError, Object? key, ShouldValidateCallback? shouldValidate, + bool allowBlank = true, }) => satisfy( - (input) => input.isNotEmpty, + (input) => allowBlank ? input.isNotEmpty : input.trim().isNotEmpty, devError: devError ?? (_) => "Value can't be empty", key: key ?? GladeErrorKeys.stringEmpty, shouldValidate: shouldValidate,