Validating custom control do dating rules matter
We first want to create a form with what’s called a “cross-field” validation. In order to make this work for us, we need to make the errors show if the form itself is invalid (since we’re talking about a form-level validation).What this means is that we want to validate data in our form, based on other data — in the same form. See that we put the validator in the form level, and not in the control level? We'll create three new components to support our event administration: a page to create events, a page to update or delete existing events, and an events form.Let's scaffold these components with the Angular CLI now: // src/app/app-routing....
We'll do a quick check to make sure, log an error, and object with the appropriate messages based on the results of validation.The sixth installment in the series covers posting data with reactive forms and implementing custom validation in Angular. Let's add the API endpoints our app's administrator needs in order to create, update, and delete events.In order to add a new event in our RSVP app, we'll create a new // server/...However, the gains include much more granular control, as well as the ability to implement robust, strongly customized validation—particularly when multiple form controls need to be validated as a group. Implementing this kind of group validation would be incredibly difficult with a template-driven form. There are many moving parts involved though, so let's do a little bit of architectural planning as well.
Here's what we'll need in order to implement our reactive form with group validation: // src/app/core/forms/form Utils....We can also execute dynamic logic whenever any value in the form has changed. This differs from template-driven forms, which are asynchronous.