-
-
Save James-Byrne/a61efbc29ba42d1353040dc6a8b291ad to your computer and use it in GitHub Desktop.
ember-changeset-validations tp demo
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'; | |
import { TeamSchema } from '../models/team'; | |
import TeamValidations from '../validations/team'; | |
const { get, Controller } = Ember; | |
export default Controller.extend({ | |
TeamValidations, | |
TeamSchema: Ember.Object.extend(TeamSchema), | |
actions: { | |
save(changeset) { | |
changeset.validate().then(() => { | |
if(get(changeset, 'isValid')) { | |
cahngeset.save(); | |
} | |
}); | |
}, | |
validateProperty(changeset, property) { | |
return changeset.validate(property); | |
}, | |
createNewTeam() { | |
// create a new team | |
} | |
} | |
}); |
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"; | |
export const TeamSchema = { | |
name: attr('string') | |
} | |
export default Model.extend(TeamSchema); | |
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({ | |
}); |
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.10.4", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"ember": "2.6.0", | |
"ember-data": "2.6.0", | |
"ember-template-compiler": "2.6.0", | |
"skeleton-css": "https://cdnjs.cloudflare.com/ajax/libs/skeleton/2.0.4/skeleton.min.css" | |
}, | |
"addons": { | |
"ember-changeset-validations": "1.2.2", | |
"ember-one-way-controls": "0.8.3" | |
} | |
} |
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 { | |
validateLength, | |
} from 'ember-changeset-validations/validators'; | |
export default { | |
name: validateLength({min: 5, max: 10}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment