Closed pixelzoom closed 3 years ago
From code review #35:
[ ] Are Validator validation options (valueType, validValues, etc...) utilized?
In AbstractNLDBaseModel.js:
this.pointValuesProperty = new Property( [ null, null ], { valueType: Array } ); this.pointValuesProperty.link( pointValues => { assert && assert( pointValues.length === 2, 'There should always be 2 point values.' ); } );
The pointValuesProperty observer can be replaced with something like:
pointValuesProperty
this.pointValuesProperty = new Property( [ null, null ], { valueType: Array, isValidValue: value => value.length === 2 } );
or a more complete/correct validation:
```js this.pointValuesProperty = new Property( [ null, null ], { valueType: Array, isValidValue: array => Array.isArray( array ) && _.every( array, element => typeof element === 'number' ) && array.length === 2 } );
I implemented the second option, but I tweaked it so that it didn't fail on null values in the array. I'll close this issue, but feel free to reopen if something more should be done.
From code review #35:
In AbstractNLDBaseModel.js:
The
pointValuesProperty
observer can be replaced with something like:or a more complete/correct validation: