TrackModel
A model of view.
Installation
npm
npm install track-view-model
Usage
const TrackModel = ; static { ; // Define model name. **Required** ; // Define `hoge.hoge` and `hoge.hoge=` ; // Define `hoge.fuga` ; // Define `hoge.piyo=` // Define accessor with onchange callback. ; // Define validation of #hoge. // (require value, and value.length <= 100) ; }
const hoge = piyo: 'PIYO'; hogehoge = 'hogehoge!';hogehoge; // => "hogehoge!" hoge; hoge; hoge; // => Object {hoge: 'abcdefg'}
Build-in validators
- PresenceValidator
ex) validate('hoge', {presence: true})
ng) null undefined ''
- LengthValidator
ex) validate('hoge', {length: {max: 10, min: 5}})
ng) 'abcd' 'abcdefghijk'
- NumericalValidator
ex) validate('hoge', {numerical: {max: 10, min: 5}})
ng) 4 11 'abc'
- FunctionValidator
ex) validate('hoge', {function: {validate: checkHoge}})
- @see FunctionValidatorExample
- FormatValidator
ex) validate('hoge', {format: {regex: /.+@.+/}})
ng) 'abcd'
FunctionValidatorExample
const Error = ;const checkHoge = { if value != 'hoge' ; else ; };