Skip to content

Commit

Permalink
Fixes a few small typos
Browse files Browse the repository at this point in the history
  • Loading branch information
lorcan committed Sep 19, 2016
1 parent b2ca89f commit d7c39b8
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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`).
Expand Down Expand Up @@ -168,7 +168,7 @@ The value must be a correct Hexadecimal color.

````js
validations: {
favoritColor:{
favoriteColor: {
color: true
}
}
Expand Down Expand Up @@ -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`).
Expand Down Expand Up @@ -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});
Expand Down Expand Up @@ -459,7 +459,7 @@ export default Model.extend(Validator,{
password: attr('string'),
passwordConfirmation: attr('string'),
bussinessEmail: attr('string', {defaultValue: '[email protected]'}),
favoritColor: attr('string', {defaultValue: '423abb'}),
favoriteColor: attr('string', {defaultValue: '423abb'}),
legacyCode: attr('string'),
mainstreamCode: attr('string', {defaultValue: 'hiphopBachatudo'}),
lotteryNumber: attr('number'),
Expand Down Expand Up @@ -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: {
Expand Down Expand Up @@ -698,7 +698,7 @@ export default Model.extend(Validator,{
}
}
});
`````
````
After setting the validations on your model you will be able to:

````js
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/models/fake-model.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default Model.extend(Validator,{
password: attr('string'),
passwordConfirmation: attr('string'),
bussinessEmail: attr('string', {defaultValue: '[email protected]'}),
favoritColor: attr('string', {defaultValue: '423abb'}),
favoriteColor: attr('string', {defaultValue: '423abb'}),
legacyCode: attr('string'),
mainstreamCode: attr('string', {defaultValue: 'hiphopBachatudo'}),
lotteryNumber: attr('number'),
Expand Down Expand Up @@ -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: {
Expand Down
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/usage.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -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});
Expand Down Expand Up @@ -215,4 +215,4 @@ export default Ember.Route.extend(
);
{{/code-block}}
</div>
</div>
</div>
4 changes: 2 additions & 2 deletions tests/dummy/app/templates/validators/hexcolor.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<p>
{{#ui-annotation showing=true type="javascript"}}
validations: {
favoritColor:{
favoriteColor:{
color: true
}
}
Expand Down Expand Up @@ -84,4 +84,4 @@ export default DS.Model.extend(Validator,{
{{/ui-annotation}}

{{/ui-example}}
</div>
</div>
14 changes: 7 additions & 7 deletions tests/unit/mixins/model-validator-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
});
});

Expand Down

0 comments on commit d7c39b8

Please sign in to comment.