Spaces:
Paused
Paused
Download node_modules/@plotly/mapbox-gl/src/style-spec/validate/validate_object.js from Leon4gr45/UserSyncFrontend: direct link, hf CLI and curl.
- Browser
- Download file 2.2 kB
-
https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/style-spec/validate/validate_object.js
- Command line
-
hf download hf://spaces/Leon4gr45/UserSyncFrontend/node_modules/@plotly/mapbox-gl/src/style-spec/validate/validate_object.js
-
curl -L -o validate_object.js https://huggingface.co/spaces/Leon4gr45/UserSyncFrontend/resolve/main/node_modules/%40plotly/mapbox-gl/src/style-spec/validate/validate_object.js
2.2 kB
| import ValidationError from '../error/validation_error'; | |
| import getType from '../util/get_type'; | |
| import validateSpec from './validate'; | |
| export default function validateObject(options) { | |
| const key = options.key; | |
| const object = options.value; | |
| const elementSpecs = options.valueSpec || {}; | |
| const elementValidators = options.objectElementValidators || {}; | |
| const style = options.style; | |
| const styleSpec = options.styleSpec; | |
| let errors = []; | |
| const type = getType(object); | |
| if (type !== 'object') { | |
| return [new ValidationError(key, object, `object expected, ${type} found`)]; | |
| } | |
| for (const objectKey in object) { | |
| const elementSpecKey = objectKey.split('.')[0]; // treat 'paint.*' as 'paint' | |
| const elementSpec = elementSpecs[elementSpecKey] || elementSpecs['*']; | |
| let validateElement; | |
| if (elementValidators[elementSpecKey]) { | |
| validateElement = elementValidators[elementSpecKey]; | |
| } else if (elementSpecs[elementSpecKey]) { | |
| validateElement = validateSpec; | |
| } else if (elementValidators['*']) { | |
| validateElement = elementValidators['*']; | |
| } else if (elementSpecs['*']) { | |
| validateElement = validateSpec; | |
| } else { | |
| errors.push(new ValidationError(key, object[objectKey], `unknown property "${objectKey}"`)); | |
| continue; | |
| } | |
| errors = errors.concat(validateElement({ | |
| key: (key ? `${key}.` : key) + objectKey, | |
| value: object[objectKey], | |
| valueSpec: elementSpec, | |
| style, | |
| styleSpec, | |
| object, | |
| objectKey | |
| }, object)); | |
| } | |
| for (const elementSpecKey in elementSpecs) { | |
| // Don't check `required` when there's a custom validator for that property. | |
| if (elementValidators[elementSpecKey]) { | |
| continue; | |
| } | |
| if (elementSpecs[elementSpecKey].required && elementSpecs[elementSpecKey]['default'] === undefined && object[elementSpecKey] === undefined) { | |
| errors.push(new ValidationError(key, object, `missing required property "${elementSpecKey}"`)); | |
| } | |
| } | |
| return errors; | |
| } | |