Created
August 9, 2017 01:45
-
-
Save blimmer/8825859866e32bf1c6a0335c2a2fd3fa to your computer and use it in GitHub Desktop.
wip multipage validations
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 Ember from 'ember'; | |
import { validator, buildValidations } from 'ember-cp-validations'; | |
import { userInfoValidations } from '../models/order'; | |
const Validations = buildValidations(userInfoValidations); | |
export default Ember.Component.extend(Validations, { | |
}); |
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 Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
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 Model from "ember-data/model"; | |
import attr from "ember-data/attr"; | |
import { validator, buildValidations } from 'ember-cp-validations'; | |
export const userInfoValidations = { | |
name: validator('presence', true), | |
email: [ | |
validator('presence', true), | |
validator('format', { type: 'email' }) | |
] | |
}; | |
export const shippingValidations = { | |
address1: validator('presence', true), | |
state: validator('presence', true), | |
zipCode: validator('presence', true) | |
}; | |
const Validations = buildValidations(Ember.assign({}, userInfoValidations, shippingValidations)); | |
export default Model.extend(Validations, { | |
name: attr('string'), | |
email: attr('string'), | |
address1: attr('string'), | |
address2: attr('string'), | |
state: attr('string'), | |
zipCode: attr('string') | |
}); |
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 Ember from 'ember'; | |
import config from './config/environment'; | |
const Router = Ember.Router.extend({ | |
location: 'none', | |
rootURL: config.rootURL | |
}); | |
Router.map(function() { | |
this.route('user-info'); | |
this.route('shipping-info'); | |
}); | |
export default Router; |
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 Ember from 'ember'; | |
export default Ember.Route.extend({ | |
model() { | |
return this.store.createRecord('order'); | |
} | |
}); |
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
{ | |
"version": "0.12.1", | |
"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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"ember-data": "2.12.1", | |
"ember-cp-validations": "3.4.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment