| const Validator = require('jsonschema').Validator; |
| const animationSchema = require('./docs/json/animation.json'); |
| const booleanSchema = require('./docs/json/helpers/boolean.json'); |
| const transformSchema = require('./docs/json/helpers/transform.json'); |
| const blendModeSchema = require('./docs/json/helpers/blendMode.json'); |
| const lineCapSchema = require('./docs/json/helpers/lineCap.json'); |
| const lineJoinSchema = require('./docs/json/helpers/lineJoin.json'); |
| const compositeSchema = require('./docs/json/helpers/composite.json'); |
| const textCapsSchema = require('./docs/json/helpers/textCaps.json'); |
| const textJustificationSchema = require('./docs/json/helpers/textJustification.json'); |
| const layerShapeSchema = require('./docs/json/layers/shape.json'); |
| const layerImageSchema = require('./docs/json/layers/image.json'); |
| const layerNullSchema = require('./docs/json/layers/null.json'); |
| const layerPreCompSchema = require('./docs/json/layers/preComp.json'); |
| const layerSolidSchema = require('./docs/json/layers/solid.json'); |
| const layerTextSchema = require('./docs/json/layers/text.json'); |
| const shapeEllipseSchema = require('./docs/json/shapes/ellipse.json'); |
| const shapeFillSchema = require('./docs/json/shapes/fill.json'); |
| const shapeGFillSchema = require('./docs/json/shapes/gFill.json'); |
| const shapeGroupSchema = require('./docs/json/shapes/group.json'); |
| const shapeGStrokeSchema = require('./docs/json/shapes/gStroke.json'); |
| const shapeMergeSchema = require('./docs/json/shapes/merge.json'); |
| const shapeRectSchema = require('./docs/json/shapes/rect.json'); |
| const shapeRepeaterSchema = require('./docs/json/shapes/repeater.json'); |
| const shapeRoundSchema = require('./docs/json/shapes/round.json'); |
| const shapeShapeSchema = require('./docs/json/shapes/shape.json'); |
| const shapeStarSchema = require('./docs/json/shapes/star.json'); |
| const shapeStrokeSchema = require('./docs/json/shapes/stroke.json'); |
| const shapeTransformSchema = require('./docs/json/shapes/transform.json'); |
| const shapeTrimSchema = require('./docs/json/shapes/trim.json'); |
| const doubleKeyframeSchema = require('./docs/json/properties/doubleKeyframe.json'); |
| const multiDimensionalSchema = require('./docs/json/properties/multiDimensional.json'); |
| const multiDimensionalKeyframedSchema = require('./docs/json/properties/multiDimensionalKeyframed.json'); |
| const multiDimensionalSpatialKeyframedSchema = require('./docs/json/properties/multiDimensionalSpatialKeyframed.json'); |
| const offsetKeyframeSchema = require('./docs/json/properties/offsetKeyframe.json'); |
| const offsetSpatialKeyframeSchema = require('./docs/json/properties/offsetSpatialKeyframe.json'); |
| const shapeSchema = require('./docs/json/properties/shape.json'); |
| const shapeKeyframedSchema = require('./docs/json/properties/shapeKeyframed.json'); |
| const shapePropSchema = require('./docs/json/properties/shapeProp.json'); |
| const shapePropKeyframeSchema = require('./docs/json/properties/shapePropKeyframe.json'); |
| const valueSchema = require('./docs/json/properties/value.json'); |
| const valueKeyframeSchema = require('./docs/json/properties/valueKeyframe.json'); |
| const valueKeyframedSchema = require('./docs/json/properties/valueKeyframed.json'); |
| const gradientSchema = require('./docs/json/properties/gradient.json'); |
| const imageSourceSchema = require('./docs/json/sources/image.json'); |
| const preCompSourceSchema = require('./docs/json/sources/precomp.json'); |
| const charSourceSchema = require('./docs/json/sources/chars.json'); |
| |
| var v = new Validator(); |
| v.addSchema(booleanSchema, '/#/helpers/boolean'); |
| v.addSchema(lineCapSchema, '/#/helpers/lineCap'); |
| v.addSchema(lineJoinSchema, '/#/helpers/lineJoin'); |
| v.addSchema(compositeSchema, '/#/helpers/composite'); |
| v.addSchema(transformSchema, '/#/helpers/transform'); |
| v.addSchema(blendModeSchema, '/#/helpers/blendMode'); |
| v.addSchema(textCapsSchema, '/#/helpers/textCaps'); |
| v.addSchema(textJustificationSchema, '/#/helpers/textJustification'); |
| v.addSchema(layerShapeSchema, '/#/layers/shape'); |
| v.addSchema(layerImageSchema, '/#/layers/image'); |
| v.addSchema(layerNullSchema, '/#/layers/null'); |
| v.addSchema(layerPreCompSchema, '/#/layers/preComp'); |
| v.addSchema(layerSolidSchema, '/#/layers/solid'); |
| v.addSchema(layerTextSchema, '/#/layers/text'); |
| v.addSchema(shapeEllipseSchema, '/#/shapes/ellipse'); |
| v.addSchema(shapeFillSchema, '/#/shapes/fill'); |
| v.addSchema(shapeGFillSchema, '/#/shapes/gFill'); |
| v.addSchema(shapeGroupSchema, '/#/shapes/group'); |
| v.addSchema(shapeGStrokeSchema, '/#/shapes/gStroke'); |
| v.addSchema(shapeMergeSchema, '/#/shapes/merge'); |
| v.addSchema(shapeRectSchema, '/#/shapes/rect'); |
| v.addSchema(shapeRepeaterSchema, '/#/shapes/repeater'); |
| v.addSchema(shapeRoundSchema, '/#/shapes/round'); |
| v.addSchema(shapeShapeSchema, '/#/shapes/shape'); |
| v.addSchema(shapeStarSchema, '/#/shapes/star'); |
| v.addSchema(shapeStrokeSchema, '/#/shapes/stroke'); |
| v.addSchema(shapeTransformSchema, '/#/shapes/transform'); |
| v.addSchema(shapeTrimSchema, '/#/shapes/trim'); |
| v.addSchema(doubleKeyframeSchema, '/#/properties/a'); |
| v.addSchema(multiDimensionalSchema, '/#/properties/multiDimensional'); |
| v.addSchema(multiDimensionalKeyframedSchema, '/#/properties/multiDimensionalKeyframed'); |
| v.addSchema(multiDimensionalSpatialKeyframedSchema, '/#/properties/multiDimensionalSpatialKeyframed'); |
| v.addSchema(offsetKeyframeSchema, '/#/properties/offsetKeyframe'); |
| v.addSchema(offsetSpatialKeyframeSchema, '/#/properties/offsetSpatialKeyframe'); |
| v.addSchema(shapeSchema, '/#/properties/shape'); |
| v.addSchema(shapeKeyframedSchema, '/#/properties/shapeKeyframed'); |
| v.addSchema(shapePropSchema, '/#/properties/shapeProp'); |
| v.addSchema(shapePropKeyframeSchema, '/#/properties/shapePropKeyframe'); |
| v.addSchema(valueSchema, '/#/properties/value'); |
| v.addSchema(valueKeyframeSchema, '/#/properties/valueKeyframe'); |
| v.addSchema(valueKeyframedSchema, '/#/properties/valueKeyframed'); |
| v.addSchema(gradientSchema, '/#/properties/gradient'); |
| v.addSchema(imageSourceSchema, '/#/sources/image'); |
| v.addSchema(preCompSourceSchema, '/#/sources/precomp'); |
| v.addSchema(charSourceSchema, '/#/sources/chars'); |
| |
| function validate(animation) { |
| return v.validate(animation, animationSchema, {nestedErrors: true}); |
| } |
| |
| module.exports = validate; |