ManuelDeLeon / viewmodel

MVVM for Meteor
https://viewmodel.org
MIT License
205 stars 23 forks source link

Validation conversions #248

Closed daveeel closed 8 years ago

daveeel commented 8 years ago

Hi @ManuelDeLeon , I'm just playing VM with the new validation function. Now I need to do the following to avoid showing NaN in a integer field

duration: ViewModel.property.integer
   .convertIn( (v)=> parseInt(v) || 0 )
   .default(2000),

Wouldn't it be nicer to let the builtin 'integer.covert' fall back to 0 if it's NaN ?

ManuelDeLeon commented 8 years ago

Sorry for the late reply. I'm going to err on the side of caution and leave it as it is (for now at least). There's something that rubs me the wrong way about changing a value underneath the dev's feet. It would be awkward if a dev does this.duration( null ) only to find the property now contains 0.