Skip to content

Field validators don't return their msg when they fail #739

@gjdv

Description

@gjdv

Whereas form level Validators set their msg in form.note in case they fail, field level Validators don't. That means that if you validate a form and somewhere a field validator fails, you have no clue which one.

Is this designed behavior? If not, may I suggest to change:
https://github.com/webpy/webpy/blob/master/web/form.py#L107

out = i.validate(v) and out

to:

if not i.validate(v):
    self.note = i.note
    return False

Instead of return False one could also do out = False, but actually I think it is better to fail first on a field validator than on a (typically more complex) form validator

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions