{"version":3,"file":"validate_terrain.mjs","names":[],"sources":["../../src/validate/validate_terrain.ts"],"sourcesContent":["import {ValidationError} from '../error/validation_error';\nimport {getType} from '../util/get_type';\nimport type {StyleSpecification, TerrainSpecification} from '../types.g';\nimport v8 from '../reference/v8.json' with {type: 'json'};\n\nexport function validateTerrain(options: {\n    value: TerrainSpecification;\n    styleSpec: typeof v8;\n    style: StyleSpecification;\n    validateSpec: Function;\n}): ValidationError[] {\n    const terrain = options.value;\n    const styleSpec = options.styleSpec;\n    const terrainSpec = styleSpec.terrain;\n    const style = options.style;\n\n    let errors = [];\n\n    const rootType = getType(terrain);\n    if (terrain === undefined) {\n        return errors;\n    } else if (rootType !== 'object') {\n        errors = errors.concat([\n            new ValidationError('terrain', terrain, `object expected, ${rootType} found`)\n        ]);\n        return errors;\n    }\n\n    for (const key in terrain) {\n        if (terrainSpec[key]) {\n            errors = errors.concat(\n                options.validateSpec({\n                    key,\n                    value: terrain[key],\n                    valueSpec: terrainSpec[key],\n                    validateSpec: options.validateSpec,\n                    style,\n                    styleSpec\n                })\n            );\n        } else {\n            errors = errors.concat([\n                new ValidationError(key, terrain[key], `unknown property \"${key}\"`)\n            ]);\n        }\n    }\n\n    return errors;\n}\n"],"mappings":";;;AAKA,SAAgB,gBAAgB,SAKV;CAClB,MAAM,UAAU,QAAQ;CACxB,MAAM,YAAY,QAAQ;CAC1B,MAAM,cAAc,UAAU;CAC9B,MAAM,QAAQ,QAAQ;CAEtB,IAAI,SAAS,CAAC;CAEd,MAAM,WAAW,QAAQ,OAAO;CAChC,IAAI,YAAY,KAAA,GACZ,OAAO;MACJ,IAAI,aAAa,UAAU;EAC9B,SAAS,OAAO,OAAO,CACnB,IAAI,gBAAgB,WAAW,SAAS,oBAAoB,SAAS,OAAO,CAChF,CAAC;EACD,OAAO;CACX;CAEA,KAAK,MAAM,OAAO,SACd,IAAI,YAAY,MACZ,SAAS,OAAO,OACZ,QAAQ,aAAa;EACjB;EACA,OAAO,QAAQ;EACf,WAAW,YAAY;EACvB,cAAc,QAAQ;EACtB;EACA;CACJ,CAAC,CACL;MAEA,SAAS,OAAO,OAAO,CACnB,IAAI,gBAAgB,KAAK,QAAQ,MAAM,qBAAqB,IAAI,EAAE,CACtE,CAAC;CAIT,OAAO;AACX"}