Skip to content

Commit

Permalink
Merge pull request #70 from netglade/feat/blank-string-validator
Browse files Browse the repository at this point in the history
Add notBlank validator
  • Loading branch information
petrnymsa authored Oct 14, 2024
2 parents df5fd2e + 3bf80be commit b49435e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions glade_forms/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
## DEV:
- **[Add]**: Add `allowBlank` parameter to `isEmpty` string validator.
- **[Add]**: Add `IntInput` as a specialized variant of GladeInput<int> 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.
Expand Down
3 changes: 2 additions & 1 deletion glade_forms/lib/src/validator/string_validator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ class StringValidator extends GladeValidator<String> {
OnValidateError<String>? devError,
Object? key,
ShouldValidateCallback<String>? 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,
Expand Down

0 comments on commit b49435e

Please sign in to comment.