Created
June 9, 2014 06:44
-
-
Save hontas/33eae2a2cbe5f4a7dacc to your computer and use it in GitHub Desktop.
Good example of bad method naming
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
validateYears: function(Class, prop) { | |
var input = Ember.get(Class, prop), | |
regex = /\D*(\d*)\.?(\d{2}).*/, | |
result; | |
if (input.length > 0) { | |
this.set('errorMsg', null); | |
if (input.match(regex)) { | |
result = input.replace(regex, "$1,$2").replace(/[,]/g, '.'); | |
} else { | |
result = input.replace(/[^,\.0-9]/g, '').replace(/[,]/g, '.'); | |
} | |
Ember.set(Class, prop, result ? result : ''); | |
} else { | |
this.set('errorMsg', App.msg.fluidQualities.calendarTimeMustBeGtThanZero); | |
} | |
}.observes('years') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment