Skip to content

Instantly share code, notes, and snippets.

@hontas
Created June 9, 2014 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hontas/33eae2a2cbe5f4a7dacc to your computer and use it in GitHub Desktop.
Save hontas/33eae2a2cbe5f4a7dacc to your computer and use it in GitHub Desktop.
Good example of bad method naming
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