-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb30016
commit cb5f82b
Showing
5 changed files
with
524 additions
and
41 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import Controller from '@ember/controller'; | ||
import { inject as service } from '@ember/service'; | ||
|
||
export default class ApplicationController extends Controller { | ||
@service store; | ||
|
||
init() { | ||
super.init(...arguments); | ||
let user = this.store.createRecord('user', { | ||
username: 'x', | ||
password: 'x', | ||
email: 'x', | ||
}); | ||
console.log(user.validations.isValid); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Model, { attr } from '@ember-data/model'; | ||
import { validator, buildValidations } from 'ember-cp-validations'; | ||
|
||
const Validations = buildValidations({ | ||
username: validator('presence', true), | ||
password: [ | ||
validator('presence', true), | ||
validator('length', { | ||
min: 4, | ||
max: 8, | ||
}), | ||
], | ||
email: [validator('presence', true), validator('format', { type: 'email' })], | ||
emailConfirmation: [ | ||
validator('presence', true), | ||
validator('confirmation', { | ||
on: 'email', | ||
message: '{description} do not match', | ||
description: 'Email addresses', | ||
}), | ||
], | ||
}); | ||
|
||
export default Model.extend(Validations, { | ||
username: attr('string'), | ||
password: attr('string'), | ||
email: attr('string'), | ||
}); |
This file contains 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
This file contains 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
Oops, something went wrong.