Skip to content

Commit

Permalink
chore: v0.5.0-dev.1 (#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
felangel authored May 3, 2022
1 parent f56e1b8 commit 3587e3d
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 5 deletions.
65 changes: 65 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,68 @@
# 0.5.0-dev.1

- docs: use nullable validator in `README`
- feat: add example Flutter app
- **BREAKING**: decouple purity, validity, and submission status

### Changes

1. `FormzStatus` renamed to `FormzSubmissionStatus`:

```dart
/// Enum representing the submission status of a form.
enum FormzSubmissionStatus {
/// The form is in the process of being submitted.
inProgress,
/// The form has been submitted successfully.
success,
/// The form submission failed.
failure,
/// The form submission has been canceled.
canceled
}
```

2. `FormzInput` class no longer exposes a `status` (`FormzInputStatus`). Instead there are `isValid` and `isNotValid` getters:

```dart
class NameInput extends FormzInput<String, NameInputError> {
const NameInput.pure() : super.pure('');
const NameInput.dirty({String value = ''}) : super.dirty(value);
@override
NameInputError? validator(String value) {
return value.isNotEmpty == true ? null : NameInputError.empty;
}
}
void main() {
const name = NameInput.pure();
print(name.isValid); // false
print(name.isNotValid); // true
const joe = NameInput.dirty(value: 'joe');
print(joe.isValid); // true
print(joe.isNotValid); // false
}
```

3. `FormzInput` has a `displayError` getter which returns an error to display if the input is not valid and has been modified by the user (closes #44)

```dart
void main() {
const name = NameInput.pure();
print(name.displayError); // null
const invalid = NameInput.dirty(value: '');
print(name.displayError); // NameInputError.empty
}
```

4. Renamed `pure` to `isPure` for consistency

# 0.4.1

- feat: add `submissionCanceled` to `FormzStatus`
Expand Down
1 change: 1 addition & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
MIT License

Copyright (c) 2020 ChicagoFlutter
Copyright (c) 2022 Very Good Ventures

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
10 changes: 5 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: formz
description: A unified form representation in Dart which aims to simplify form representation and validation in a generic way.
repository: https://github.com/ChicagoFlutter/formz
issue_tracker: https://github.com/ChicagoFlutter/formz/issues
homepage: https://github.com/ChicagoFlutter/formz
documentation: https://github.com/ChicagoFlutter/formz
repository: https://github.com/VeryGoodOpenSource/formz
issue_tracker: https://github.com/VeryGoodOpenSource/formz/issues
homepage: https://github.com/VeryGoodOpenSource/formz
documentation: https://github.com/VeryGoodOpenSource/formz

version: 0.4.1
version: 0.5.0-dev.1

environment:
sdk: ">=2.14.0 <3.0.0"
Expand Down

0 comments on commit 3587e3d

Please sign in to comment.