Skip to content

Switch suggestion #525

@jgardiner68

Description

@jgardiner68

ChatGPT suggested that this was valid -- it looks wonderful:

from voluptuous import Schema, Required, All, Length, Switch, Invalid

# Define the schema with Switch
schema = Schema({
    'issuetype': str,
    Switch('issuetype', {
        'Feature Request': Schema({
            Required('feature_details'): All(str, Length(min=10)),
        }),
        'Bug': Schema({
            Required('bug_report'): All(str, Length(min=5)),
        }),
    }),
})

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