Using Ember validations

Data form validation is a very common use case in web development. The end user will know immediately if they've made a mistake when you create validation rules in your application.

In this recipe, we'll take a look at two examples on validation. In the first example, we'll use a component and check data based on a few simple validation rules. In the second example, we'll use a popular Ember add-on to make things easier.

How to do it...

  1. In a new application, create two components and install the validation add-on:
    $ ember g component val-example
    $ ember g component val-example2
    $ ember install ember-cp-validations
    

    The val-example component will be the first example. The val-example2 component will be the second example using ...

Get Ember.js Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.