A short trip into Reactive Forms Validation | Armela Gjoka | Lightning Talks 2021 #ngconf
Most applications require some user input and since we can not guarantee that the user enters valid input, we have to set in place some rules before sending data to the backend.
She has been working for some time with forms, both template-driven and reactive, and one of the challenges is to decide whether validation should be handled in the frontend or the backend. She believes that a mix of both is the right combination.
Frontend should handle these types of validations:
Required or optional.
Format: minLength, maxLength, pattern match.
Other validations that are easily understandable to any UI user, such as: password and confirm password should have the same value.
On the other hand, any validation that is specific to the business logic should be handled in the backend.
She discussed Reactive Forms since they are more scalable and a large form will probably have many rules. There are three main categories of validators that we can apply to a form control.
Built-in Validators
Custom Validators
Async Validators
She applied these validators in a form control and showed how they are implemented and their behaviour.
Learn the best ways to build reliable web applications, write quality code, choose scalable architectures, and create effective automated tests at the Reliable Web Summit this August 26-27, 2021. Powered by the team at ng-conf.
Get your ticket 👉 https://reliablewebsummit.com/
ng-conf is a multi-day Angular conference focused on delivering the highest quality training in the Angular JavaScript framework. 1000's of developers from across the globe join together to attend talks and workshops by the Angular team and other community experts.
Follow us on twitter https://twitter.com/ngconf
Official Website: https://www.ng-conf.org/