Created
December 30, 2016 01:56
-
-
Save stephencarr/53c8c0e11f326de432cc543f69c12f4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import DS from 'ember-data'; | |
import {validator, buildValidations} from 'ember-cp-validations'; | |
const Validations = buildValidations({ | |
username: [ | |
validator('presence', true), | |
validator('length', { | |
min: 5, | |
max: 15 | |
}) | |
], | |
password: [ | |
validator('presence', true), | |
validator('length', { | |
min: 4, | |
max: 10 | |
}), | |
validator('format', { | |
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,10}$/, | |
message: '{description} must include at least one upper case letter, one lower case letter, and a number' | |
}), | |
validator('length', { | |
isWarning: true, | |
min: 6, | |
message: 'What kind of weak password is that?' | |
}) | |
], | |
password_confirmation: [ | |
validator('presence', true), | |
validator('length', { | |
min: 4, | |
max: 10 | |
}), | |
validator('format', { | |
regex: /^(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{4,10}$/, | |
message: '{description} must include at least one upper case letter, one lower case letter, and a number' | |
}), | |
validator('length', { | |
isWarning: true, | |
min: 6, | |
message: 'What kind of weak password is that?' | |
}) | |
], | |
email: [ | |
validator('presence', true), | |
validator('format', {type: 'email'}) | |
] | |
}, {debounce: 500}); | |
export default DS.Model.extend(Validations, { | |
locale: DS.attr('string'), | |
email: DS.attr('string'), | |
username: DS.attr('string'), | |
first_name: DS.attr('string'), | |
last_name: DS.attr('string'), | |
password: DS.attr('string'), | |
password_confirmation: DS.attr('string'), | |
birthday: DS.attr('date'), | |
device_attributes: { | |
os: DS.attr('string'), | |
uid: DS.attr('string') | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment