Releases: esbanarango/ember-model-validator
Releases · esbanarango/ember-model-validator
v.3.13.0
What's Changed
- Fix for
model.validate()
causes error. (#185 reported by @ollar) - Bump ember-composable-helpers from 3.2.0 to 5.0.0 by @dependabot in #187
- Bump ember-source-channel-url from 2.0.1 to 3.0.0 by @dependabot in #190
Full Changelog: v3.12.0...v.3.13.0
v3.12.0
What's Changed
- Bump tmpl from 1.0.4 to 1.0.5 by @dependabot in #180
- Bump prismjs from 1.24.1 to 1.25.0 by @dependabot in #179
- Bump ember-angle-bracket-invocation-polyfill from 2.1.0 to 3.0.1 by @dependabot in #175
- Update README.md by @adriguy in #183
- Use ES module Ember import for addon version by @charlesfries in #186
New Contributors
- @adriguy made their first contribution in #183
- @charlesfries made their first contribution in #186
Full Changelog: v3.11.0...v3.12.0
Release v3.11.0
💥 Breaking Change
Decorator instead of mixin
Before
import Model from "ember-data/model";
import attr from "ember-data/attr";
import Validator from "ember-model-validator/mixins/object-validator";
export default Model.extend(Validator, {
fullName: attr("string"),
fruit: attr("string"),
color: attr("string"),
validations: {
fullName: {
presence: true
},
fruit: {
presence: true
}
}
});
After
import Model from 'ember-data/model';
import attr from 'ember-data/attr';
import Validator from 'ember-model-validator/decorators/model-validator';
@Validator
class MyModel extends Model {
@attr("string") fullName;
@attr("string") fruit;
@attr("string") color;
validations = {
fullName: {
presence: true
},
fruit: {
presence: true
}
}
}
export default MyModel;
Adding exclusion validator and support for custom message.
validations: {
name: {
presence: true,
inclusion: { in: ['Jose Rene', 'Aristi Gol', 'Armani'], message: 'Solo verde a morir' }
},
secondName: {
exclusion: { in: ['Gionvany Hernandez', 'Wilder Medina'], message: 'Que iNrresponsabilidad' }
},
bussinessEmail: {
presence: { message: 'sup dude, where\'s da email' },
email: { message: 'Be professional ma men' }
},
mainstreamCode: {
format: { with: /^[a-zA-Z]+$/, message: 'nu nu, that\'s not the format' }
}
alibabaNumber: {
numericality: { message: 'is not abracadabra' }
}
}
Addition of Format validator + default messages.
format: {with: /^[a-zA-Z]+$/}
New DSL to define validations + Numericality
Before:
validations: {
presence: ['name','email'],
email: ['email'],
relations: {
hasMany:['otherFakes']
}
}
Now:
validations: {
name: {
presence: true
},
email: {
presence: true,
email: true
},
lotteryNumber: {
numericality: true
},
otherFakes:{
relations: ['hasMany']
}
}
Basic validations / First release!
0.0.1 Version 0.0.1