python-jsonschema / python-jsonschema/jsonschema

Ensure extended validators can create keywords which override exception messages

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

Nobody has claimed this yet.

Dialects v2 Enhancement
Dominant language
Python
Stars
5k
Forks
671
Avg merge
1d 1h
Merged PRs (30d)
10

Description

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?

Contributor guide

Open the contributing guide

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.

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.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.