Ensure extended validators can create keywords which override exception messages

Open
#1,134 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 6 days

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
backend

Research direction

No file or test entry point is named in the issue. Start by reading the validator and extended-validator documentation, then locate how exception messages are produced; done means an extended validator can define schema keywords that override those messages, with coverage for the example behavior.

Written by the indexing model from the issue text.

Description

Dialects v2 Enhancement

Hi, first of all, thanks for all your work with this package.

All in all i think it works great and really does what it should and is supposed to do.
I think that if i should mention anything that i think could be better it would probably be better error messages, now i do understand that it is really hard to generate good error messages for all use cases but something that could be very useful is the option to add custom error messages.

Here is an example.

{
    "type": "object",
    "properties": {
        "templates": {
            "type": "object",
            "properties": {
                   "path": {"type": "string", "minLength": 1, "pattern": "^(/[^/]+)+$", "message": {"pattern": "You must use a valid full path with no trailing slashes"}}},
            "required": ["path"],
        },
    },
    "required": ["templates"],
}

I've read the documentation and haven't been able to find a way to define custom messages in the schema, but maybe i have missed something?

Dominant language
Python
Stars
5k
Forks
741
Avg merge
4d 17h
Merged PRs (30d)
6

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from python-jsonschema/jsonschema

All issues in python-jsonschema/jsonschema

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.