feat(form): add raw form validator
This commit is contained in:
parent
24ebdc008c
commit
a1e36f84be
@ -28,4 +28,8 @@ abstract class FormValidator {
|
|||||||
.every((validator) => validator.pure);
|
.every((validator) => validator.pure);
|
||||||
|
|
||||||
FormStatus validate(FormData form);
|
FormStatus validate(FormData form);
|
||||||
|
|
||||||
|
FormStatus rawValidate(
|
||||||
|
List<FormInputValidator<dynamic, ValidationError>> validators,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,14 @@ class EveryInputValidator extends FormValidator {
|
|||||||
return FormStatus.pure;
|
return FormStatus.pure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (form
|
return rawValidate(form.validators<dynamic, ValidationError>());
|
||||||
.validators<dynamic, ValidationError>()
|
}
|
||||||
.any((validator) => validator.valid == false)) {
|
|
||||||
|
@override
|
||||||
|
FormStatus rawValidate(
|
||||||
|
List<FormInputValidator<dynamic, ValidationError>> validators,
|
||||||
|
) {
|
||||||
|
if (validators.any((validator) => validator.valid == false)) {
|
||||||
return FormStatus.invalid;
|
return FormStatus.invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
// You should have received a copy of the GNU General Public License
|
// You should have received a copy of the GNU General Public License
|
||||||
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
// along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
export 'form/every_input_validator.dart';
|
||||||
export 'inputs/base/regex_validator.dart';
|
export 'inputs/base/regex_validator.dart';
|
||||||
export 'inputs/base/text_validator.dart';
|
export 'inputs/base/text_validator.dart';
|
||||||
export 'inputs/boolean.dart';
|
export 'inputs/boolean.dart';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user