improvements
This commit is contained in:
@@ -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)?$/}
|
||||
|
||||
Reference in New Issue
Block a user