planning
All checks were successful
Publish To Prod / deploy_and_publish (push) Successful in 35s

This commit is contained in:
2024-10-14 09:15:30 +02:00
parent bcba00a730
commit 6e64e138e2
21059 changed files with 2317811 additions and 1 deletions

View File

@@ -0,0 +1,34 @@
// @flow
import ValidationError from '../error/validation_error.js';
import getType from '../util/get_type.js';
import validate from './validate.js';
import type {ValidationOptions} from './validate.js';
export default function validateProjection(options: ValidationOptions): Array<ValidationError> {
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;
}