Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Form level validation workflow #12772

Open
wbyoko opened this issue Sep 7, 2015 · 3 comments
Open

Form level validation workflow #12772

wbyoko opened this issue Sep 7, 2015 · 3 comments

Comments

@wbyoko
Copy link
Contributor

wbyoko commented Sep 7, 2015

Angular 1.x

Simplest case would be checking that passwords match.

This form validation fiddle (http://jsfiddle.net/cafau/Ja2ar/) does the job using $scope.$watch.

Could some option become available to allow the addition of validations through directives using a required form controller.

@Narretz
Copy link
Contributor

Narretz commented Sep 8, 2015

What else do you have in mind? Validating single fields is pretty well supported. Validating / comparing multiple fields is not straight-forward, that is true.

@gkalpak
Copy link
Member

gkalpak commented Sep 8, 2015

@Narretz, it is indeed a pain-point to have a field match the value of another field (e.g. password and password confirmation).

The main issue (imo) is that it is not possible (in a reasonably straight-forward way) to trigger validation on a field if the field's value has not changed (even if a field affecting one of its validators has changed).

Maybe, it would be useful to have a (public) way of "forcing" the parse/validate pipeline (even if the $viewValue hasn't changed).

WDYT ?

@wbyoko
Copy link
Contributor Author

wbyoko commented Sep 8, 2015

Would hope one could add $validator methods on a FormController, similar to NgModelController except that possibly no value would be passed, data would be brought in through services or a non-isolated scope.

To have a way of separating this logic from the controller, which could get bloated; run these checks when form changes and not on form submission or via explicit $scope.$watch; and hook into $error to be able to show error messages.

Form level check are used to validate that information is congruent throughout the form.

  • If a child has a birthdate that is earlier than the parent. (Dynamic List of people with relationships)
  • If someone tries to make multiple withdrawals worth more than a maximum or more than what they stated they would withdraw. (Dynamic List of withdrawal slips / sum?)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants