Would you like to clone this notebook?

When you clone a notebook you are able to make changes without affecting the original notebook.

Cancel

eslint-plugin-react with imjv

node v6.17.1
version: master
endpointsharetweet
const imjv = require('is-my-json-valid'); const SPACING = { always: 'always', never: 'never' }; const SPACING_VALUES = [SPACING.always, SPACING.never]; var schema = { type: 'array', items: [ { definitions: { basicConfig: { type: 'object', properties: { when: { enum: SPACING_VALUES }, allowMultiline: { type: 'boolean' }, spacing: { type: 'object', properties: { objectLiterals: { enum: SPACING_VALUES } } } } }, basicConfigOrBoolean: { oneOf: [{ $ref: '#/definitions/basicConfig' }, { type: 'boolean' }] } }, oneOf: [{ allOf: [{ $ref: '#/definitions/basicConfig' }, { type: 'object', properties: { attributes: { $ref: '#/definitions/basicConfigOrBoolean' }, children: { $ref: '#/definitions/basicConfigOrBoolean' } } }] }, { enum: SPACING_VALUES }] }, { type: 'object', properties: { allowMultiline: { type: 'boolean' }, spacing: { type: 'object', properties: { objectLiterals: { enum: SPACING_VALUES } } } }, additionalProperties: false } ], minItems: 0, maxItems: 2 }; const validate = imjv(schema, { verbose: true }); console.log('#1', validate([{ when: 'never', spacing: {objectLiterals: 'whatever'}, attributes: true }])); console.log('#2', validate([{ when: 'never', spacing: {objectLiterals: 'whatever'}, attributes: true, children: {when: 'whatever'} }]));
Loading…

no comments

    sign in to comment