Created
March 20, 2018 10:35
-
-
Save zeppelin/fce2bf7dbdcc664be3668832d56ebef6 to your computer and use it in GitHub Desktop.
cp-validations-default-value
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
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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
import Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { belongsTo, hasMany } from "ember-data/relationships"; | |
import { validator, buildValidations } from 'ember-cp-validations'; | |
const Validations = buildValidations({ | |
email1: [ | |
validator('format', { | |
type: 'email' | |
}) | |
], | |
email2: [ | |
validator('format', { | |
type: 'email' | |
}) | |
] | |
}); | |
export default Model.extend({ | |
email1: attr({ defaultValue: 'hello' }), | |
email2: attr({ defaultValue: () => 'hello' }) | |
}); |
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
import Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
let book = this.store.createRecord('book'); | |
console.log(book.changedAttributes()); | |
return book; | |
} | |
}); |
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
{ | |
"version": "0.13.0", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "release", | |
"ember-template-compiler": "release", | |
"ember-testing": "release" | |
}, | |
"addons": { | |
"ember-data": "2.16.3", | |
"ember-cp-validations": "*" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment