improvements

This commit is contained in:
2015-02-18 23:42:56 +01:00
parent c1858455e9
commit a1474e934a
4 changed files with 15 additions and 9 deletions
@@ -1,5 +1,5 @@
attr = DS.attr
App.Product = DS.Model.extend
App.Product = DS.Model.extend Ember.Validations.Mixin,
name: attr 'string'
price: attr 'number'
code: attr 'string'
@@ -17,8 +17,11 @@ App.Product = DS.Model.extend
image
).property('image')
isValid: (->
return false unless price = @get('price')
return false unless "#{price}".match(/^[+-]?\d+(\.?\d?\d)?$/)
true
).property('price')
#isValid: (->
#return false unless price = @get('price')
#return false unless "#{price}".match(/^[+-]?\d+(\.?\d?\d)?$/)
#true
#).property('price')
validations:
name: {presence: true}
price: {format: /^[+-]?\d+(\.?\d?\d)?$/}