-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
48de483
commit 9f4a3c4
Showing
3 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ValidationError from '../error/validation_error.js'; | ||
import getType from '../util/get_type.js'; | ||
import validate from './validate.js'; | ||
|
||
export default function validateImage(options) { | ||
const projection = options.value; | ||
const styleSpec = options.styleSpec; | ||
const projectionSpec = styleSpec.projection; | ||
const style = options.style; | ||
|
||
let errors = []; | ||
|
||
const rootType = getType(projection); | ||
|
||
if (rootType === 'object') { | ||
for (const key in projection) { | ||
errors = errors.concat(validate({ | ||
key, | ||
value: projection[key], | ||
valueSpec: projectionSpec[key], | ||
style, | ||
styleSpec | ||
})); | ||
} | ||
} else if (rootType !== 'string') { | ||
errors = errors.concat([new ValidationError('projection', projection, `object or string expected, ${rootType} found`)]); | ||
} | ||
|
||
return errors; | ||
} |