diff --git a/README.md b/README.md index 9eb43e62..b20196b4 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ Validates that the specified attributes are absent. It uses [Ember.isPresent](ht ```` ### Format -Speficy a Regexp to validate with. It uses the [match()](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/match) method from String. +Specify a Regex to validate with. It uses the [match()](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/String/match) method from String. ````js validations: { @@ -92,7 +92,7 @@ Speficy a Regexp to validate with. It uses the [match()](https://developer.mozil ```` ### Length -Speficy the lengths that are allowed. +Specify the lengths that are allowed. ##### Options - A `number`. The exact length of the value allowed (Alias for `is`). @@ -168,7 +168,7 @@ The value must be a correct Hexadecimal color. ````js validations: { - favoritColor:{ + favoriteColor: { color: true } } @@ -219,7 +219,7 @@ The value can't be included in a given set. ```` ### Match -Speficy the attribute to match with. +Specify the attribute to match with. ##### Options - A `string`. The name of the attribute to match with (Alias for `attr`). @@ -428,7 +428,7 @@ You can also pass an _option_ hash for excluding or forcing certain attributes t myModel.validate({except:['name', 'cellphone']}); //Using `only` -myModel.validate({only:['favoritColor', 'mainstreamCode']}); +myModel.validate({only:['favoriteColor', 'mainstreamCode']}); //Using `addErrors` myModel.validate({addErrors:false}); @@ -459,7 +459,7 @@ export default Model.extend(Validator,{ password: attr('string'), passwordConfirmation: attr('string'), bussinessEmail: attr('string', {defaultValue: 'donJoseRene@higuita.com'}), - favoritColor: attr('string', {defaultValue: '423abb'}), + favoriteColor: attr('string', {defaultValue: '423abb'}), legacyCode: attr('string'), mainstreamCode: attr('string', {defaultValue: 'hiphopBachatudo'}), lotteryNumber: attr('number'), @@ -555,7 +555,7 @@ export default Model.extend(Validator,{ presence: { message: 'sup dude, where\'s da email' }, email: { message: 'Be professional ma men' } }, - favoritColor:{ + favoriteColor:{ color: { message: 'not a hex color' } }, email: { @@ -698,7 +698,7 @@ export default Model.extend(Validator,{ } } }); -````` +```` After setting the validations on your model you will be able to: ````js diff --git a/tests/dummy/app/models/fake-model.js b/tests/dummy/app/models/fake-model.js index 481c4945..7dfe5c41 100644 --- a/tests/dummy/app/models/fake-model.js +++ b/tests/dummy/app/models/fake-model.js @@ -17,7 +17,7 @@ export default Model.extend(Validator,{ password: attr('string'), passwordConfirmation: attr('string'), bussinessEmail: attr('string', {defaultValue: 'donJoseRene@higuita.com'}), - favoritColor: attr('string', {defaultValue: '423abb'}), + favoriteColor: attr('string', {defaultValue: '423abb'}), legacyCode: attr('string'), mainstreamCode: attr('string', {defaultValue: 'hiphopBachatudo'}), lotteryNumber: attr('number'), @@ -113,7 +113,7 @@ export default Model.extend(Validator,{ presence: { message: 'sup dude, where\'s da email' }, email: { message: 'Be professional ma men' } }, - favoritColor:{ + favoriteColor:{ color: { message: 'not a hex color' } }, email: { diff --git a/tests/dummy/app/templates/usage.hbs b/tests/dummy/app/templates/usage.hbs index cd91ae8f..154e49e6 100644 --- a/tests/dummy/app/templates/usage.hbs +++ b/tests/dummy/app/templates/usage.hbs @@ -53,7 +53,7 @@ if(myModel.validate()){ myModel.validate({except:['name', 'cellphone']}); //Using `only` -myModel.validate({only:['favoritColor', 'mainstreamCode']}); +myModel.validate({only:['favoriteColor', 'mainstreamCode']}); //Using `addErrors` myModel.validate({addErrors:false}); @@ -215,4 +215,4 @@ export default Ember.Route.extend( ); {{/code-block}} - \ No newline at end of file + diff --git a/tests/dummy/app/templates/validators/hexcolor.hbs b/tests/dummy/app/templates/validators/hexcolor.hbs index 3fa320b7..52581da3 100644 --- a/tests/dummy/app/templates/validators/hexcolor.hbs +++ b/tests/dummy/app/templates/validators/hexcolor.hbs @@ -21,7 +21,7 @@
{{#ui-annotation showing=true type="javascript"}} validations: { - favoritColor:{ + favoriteColor:{ color: true } } @@ -84,4 +84,4 @@ export default DS.Model.extend(Validator,{ {{/ui-annotation}} {{/ui-example}} - \ No newline at end of file + diff --git a/tests/unit/mixins/model-validator-test.js b/tests/unit/mixins/model-validator-test.js index 8d58300e..133fdeb7 100644 --- a/tests/unit/mixins/model-validator-test.js +++ b/tests/unit/mixins/model-validator-test.js @@ -170,12 +170,12 @@ describe('ModelValidatorMixin', function() { }); it('validates the color format of the attributes set on `validations.color`', function() { - var model = this.subject({favoritColor:'000XXX'}), - message = model.validations.favoritColor.color.message; - delete model.validations.favoritColor.color.message; + var model = this.subject({favoriteColor:'000XXX'}), + message = model.validations.favoriteColor.color.message; + delete model.validations.favoriteColor.color.message; expect(model.validate()).to.equal(false); - expect(model.get('errors').errorsFor('favoritColor').mapBy('message')[0][0]).to.equal(Messages.colorMessage); - model.validations.favoritColor.color['message'] = message; + expect(model.get('errors').errorsFor('favoriteColor').mapBy('message')[0][0]).to.equal(Messages.colorMessage); + model.validations.favoriteColor.color['message'] = message; }); it('validates the numericality of the attributes set on `validations.numericality`', function() { @@ -508,10 +508,10 @@ describe('ModelValidatorMixin', function() { }); it('validates the color format of the attributes set on `validations.color` and use the correct message', function() { - var model = this.subject({favoritColor:'adsfasdf$'}); + var model = this.subject({favoriteColor:'adsfasdf$'}); Ember.run(function() { expect(model.validate()).to.equal(false); - expect(model.get('errors').errorsFor('favoritColor').mapBy('message')[0][0]).to.equal(model.validations.favoritColor.color.message); + expect(model.get('errors').errorsFor('favoriteColor').mapBy('message')[0][0]).to.equal(model.validations.favoriteColor.color.message); }); });