Last active
December 15, 2015 21:06
-
-
Save nummi/8510a62ea669bd6c626d to your computer and use it in GitHub Desktop.
Aperta-Validation
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
| const Validations = buildValidations({ | |
| pfaQuestion1b: validator('pfa-number', true) | |
| }); | |
| export default TaskController.extend(Validations, { | |
| pfaQuestion1bAnswer: computed('model.nestedQuestions.[]', function() { | |
| return this.get('model').answerForQuestion('pfa_question_1b'); | |
| }), | |
| pfaQuestion1b: computed.alias('pfaQuestion1bAnswer.value') | |
| }); |
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 BaseValidator from 'ember-cp-validations/validators/base'; | |
| const numericMessage = "Must be a number and contain no symbols, or letters, e.g. $1,000.00 should be written 1000"; | |
| export default BaseValidator.extend({ | |
| validate(value, options, obj) { | |
| if(!obj.get('pfa')) { return false; } | |
| const parsed = parseInt(value); | |
| if(typeof parsed === 'number' && !isNaN(parsed)) { | |
| return false; | |
| } | |
| return numericMessage; | |
| } | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment