Skip to content

Proposal: Support for "default" values, output document with defaults, accept "default" values for "required" fields #89

@Garagoth

Description

@Garagoth

Given the schema:

{
    "$id": "https://jschon.dev/schema",
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "required": ["p1", "p2"],
    "properties": {
        "p1": {"type": "string", "default": "def_val"},
        "p2": {"type": "integer", "default": 7, "minimum": 5},
        "p3": {"type": "string"}
    }
}

following document does not validate:

{
    "p2": 6,
    "p3": "test_p3"
}

Finally, as a result of validation, I would like to be able to get document that was validated extended with all fields with default values that were not present in original document.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions