File tree Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Expand file tree Collapse file tree 1 file changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -35,11 +35,29 @@ ember install ember-cp-validations
3535Usage
3636------------------------------------------------------------------------------
3737
38- Define your model and its validations as described in [ Ember CP Validations] ( https://github.com/offirgolan/ember-cp-validations ) .
38+ Define your model and its validations as described in [ Ember CP Validations] ( https://github.com/offirgolan/ember-cp-validations ) :
39+
40+ ``` js
41+ import Ember from ' ember' ;
42+ import { validator , buildValidations } from ' ember-cp-validations' ;
43+
44+ const Validations = buildValidations ({
45+ username: validator (' presence' , true ),
46+ email: validator (' format' , { type: ' email' }),
47+ password: validator (' length' , { min: 10 }),
48+ });
49+
50+ export default Ember .Component .extend (Validations, {
51+ username: null ,
52+ email: null ,
53+ password: null ,
54+ });
55+ ```
56+
3957Then assign the model to your form:
4058
4159``` hbs
42- <BsForm @model={{changeset this.user this.userValidations }} as |form|>
60+ <BsForm @model={{this}} as |form|>
4361 <form.element @label="Username" @controlType="text" @property="username" />
4462 <form.element @label="Email" @controlType="email" @property="email" />
4563 <form.element @label="Password" @controlType="password" @property="password" />
You can’t perform that action at this time.
0 commit comments