viur-framework / viur-core

The core component of ViUR, the Python framework for modern web development.
https://www.viur.dev
MIT License
13 stars 14 forks source link

Dynamic skeleton validation #1260

Open phorward opened 1 month ago

phorward commented 1 month ago

Theoretical scribble as an idea?

class TodoSkel(skeleton.Skeleton):

    name = StringBone(
        descr="Name",
    )

    status = SelectBone(
        descr="Status",
        required=True,
        defaultValue="open",
        values={
            "open": "Offen",
            "pending": "In Bearbeitung",
            "closed": "Geschlossen",
        },
    )

    test = StringBone(
        descr="Test",
        required=""" name == "Jan" """,
        validate=("None if len(test) > 10 else 'Too short'", re.compile(r"ab.*")),
        readonly=""" status == "open" """,
        visible=""" status in ("pending", "closed") """,
    )
phorward commented 1 month ago

Relates to #1207