Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: exclude/include paths in schema validation #45

Open
DougForst opened this issue Jun 12, 2020 · 1 comment
Open

Feature Request: exclude/include paths in schema validation #45

DougForst opened this issue Jun 12, 2020 · 1 comment

Comments

@DougForst
Copy link

It would be nice if the schema validation supported options to allow passing in a list of json paths to include and/or exclude.

For example:

const jsonData = {
    links: {
        first: 'http://example.com/events/12345',
    },
    data: {
        type: 'event',
        id: '01e84900-8c10-4234-9576-787fb8897399',
        attributes: {
            name: 'My Event',
        },
        relationships: {
            createdByUser: {
                data: { id: '123245', type: 'User' },
            },
        },
    },
    jsonapi: {
        version: '1.0',
    },
};

// Exclude jsonapi and data.relationships when comparing the schema
context.assert(jsonData).schema(fileName, true, { exclude: ['jsonapi', 'data.relationships'] });

// Only include links and the data objects when comparing the schema
context.assert(jsonData).schema(fileName, true, { include: ['links', 'data'] });
@jasonbyrne
Copy link
Collaborator

I think it's a nice idea. The only problem with it is that AJV does not have this feature as far as I can tell. Trying to maintain compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants