Created
August 10, 2016 09:24
-
-
Save shellandbull/82459e1a4483038a26569f299a7960da to your computer and use it in GitHub Desktop.
sample-validated-input
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'; | |
const { computed, isPresent } = Ember; | |
export default Ember.Component.extend({ | |
errors: null, | |
label: null, | |
value: computed('errors', { | |
get() { return null; }, | |
set(_,v) { | |
let { label, errors } = this.getProperties('errors', 'label'); | |
if (v === 'invalid' && errors) { | |
console.log('failed'); | |
errors.add(label, 'is invalid'); | |
return v; | |
} else if (errors) { | |
errors.remove(label); | |
return v; | |
} | |
} | |
}), | |
}); |
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 DS from 'ember-data'; | |
const { Errors } = DS; | |
export default Ember.Controller.extend({ | |
appName: 'Validated input', | |
name: '', | |
init() { | |
this._super(...arguments); | |
this.set('errors', Errors.create()); | |
} | |
}); |
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.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.7.0", | |
"ember-data": "2.7.0", | |
"ember-template-compiler": "2.7.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment