File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,19 +26,29 @@ function limitedNumber(min, max) {
2626
2727 const err = [ ] ;
2828
29- value = parseInt ( value , 10 ) ;
30-
31- if ( ! isNumber ( value ) || isNaN ( value ) ) {
32- err . push ( 'Not a valid number!' ) ;
29+ if ( Array . isArray ( value ) ) {
30+ for ( const entry of value ) {
31+ checkNumber ( entry , min , max , err ) ;
32+ }
3333 } else {
34- if ( value > max ) err . push ( 'Value too big!' ) ;
35- else if ( value < min ) err . push ( 'Value too small!' ) ;
34+ checkNumber ( value , min , max , err ) ;
3635 }
3736
3837 return err ;
3938 } ;
4039}
4140
41+ function checkNumber ( value , min , max , err ) {
42+ value = Number ( value ) ;
43+
44+ if ( ! isNumber ( value ) || isNaN ( value ) ) {
45+ err . push ( 'Not a valid number!' ) ;
46+ } else {
47+ if ( value > max ) err . push ( 'Value too big!' ) ;
48+ else if ( value < min ) err . push ( 'Value too small!' ) ;
49+ }
50+ }
51+
4252function limitedString ( min , max ) {
4353 return function ( value , schema ) {
4454 const emptyError = checkEmpty ( value , schema . required ) ;
You can’t perform that action at this time.
0 commit comments