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

How to set a global error message for required fields in all subschemas #30

Open
ruscoder opened this issue Apr 19, 2019 · 0 comments
Open

Comments

@ruscoder
Copy link

ruscoder commented Apr 19, 2019

Hello, thanks for the library!

My schema looks like:

{
    if: {
        properties: {
            fieldType: {
                const: 'field1',
            },
        },
        required: ['fieldType'],
    },
    then: {
        $ref: '#/definitions/customDefinition',
        required: ['field1'],
        errorMessage: {
            required: 'Required',
        },
    },
    else: {
        $ref: '#/definitions/customDefinition',
        required: ['field2'],
        errorMessage: {
            required: 'Required',
        },
    },
    definitions: {
        customDefinition: {
            type: 'object',
            properties: { date: { format: 'date' } },
            required: ['date'],
            errorMessage: {
                properties: { date: 'Custom error message' },
                required: 'Required',
            },
        },
    },
    errorMessage: {
        required: 'Required',
    },
};

Now I need to copy-paste

    errorMessage: {
        required: 'Required',
    },

in each subschema.

Is there an ability to set a global error message for required fields?

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

No branches or pull requests

1 participant