Spaces:
Paused
Paused
Download node_modules/@plotly/mapbox-gl/src/style-spec/validate/validate_array.js from Leon4gr45/UserSyncFrontend: direct link, hf CLI and curl.
- Browser
- Download file 1.65 kB
-
https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/style-spec/validate/validate_array.js
- Command line
-
hf download hf://spaces/Leon4gr45/UserSyncFrontend/node_modules/@plotly/mapbox-gl/src/style-spec/validate/validate_array.js
-
curl -L -o validate_array.js https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/style-spec/validate/validate_array.js
1.65 kB
| import getType from '../util/get_type'; | |
| import validate from './validate'; | |
| import ValidationError from '../error/validation_error'; | |
| export default function validateArray(options) { | |
| const array = options.value; | |
| const arraySpec = options.valueSpec; | |
| const style = options.style; | |
| const styleSpec = options.styleSpec; | |
| const key = options.key; | |
| const validateArrayElement = options.arrayElementValidator || validate; | |
| if (getType(array) !== 'array') { | |
| return [new ValidationError(key, array, `array expected, ${getType(array)} found`)]; | |
| } | |
| if (arraySpec.length && array.length !== arraySpec.length) { | |
| return [new ValidationError(key, array, `array length ${arraySpec.length} expected, length ${array.length} found`)]; | |
| } | |
| if (arraySpec['min-length'] && array.length < arraySpec['min-length']) { | |
| return [new ValidationError(key, array, `array length at least ${arraySpec['min-length']} expected, length ${array.length} found`)]; | |
| } | |
| let arrayElementSpec = { | |
| "type": arraySpec.value, | |
| "values": arraySpec.values | |
| }; | |
| if (styleSpec.$version < 7) { | |
| arrayElementSpec.function = arraySpec.function; | |
| } | |
| if (getType(arraySpec.value) === 'object') { | |
| arrayElementSpec = arraySpec.value; | |
| } | |
| let errors = []; | |
| for (let i = 0; i < array.length; i++) { | |
| errors = errors.concat(validateArrayElement({ | |
| array, | |
| arrayIndex: i, | |
| value: array[i], | |
| valueSpec: arrayElementSpec, | |
| style, | |
| styleSpec, | |
| key: `${key}[${i}]` | |
| })); | |
| } | |
| return errors; | |
| } | |