durusmail: qp: ConnectiveSpecOperator: how to know which spec gave out?
ConnectiveSpecOperator: how to know which spec gave out?
2006-02-26
2006-02-27
2006-02-27
2006-02-27
2006-02-27
2006-02-27
2006-02-28
2006-02-28
ConnectiveSpecOperator: how to know which spec gave out?
David Binger
2006-02-28
On Feb 27, 2006, at 3:48 PM, mario ruggier wrote:

>         form.add_password('passwd1', title="Password Confirm",
>             required=False,
>             hint="Case sensitive. At least 4 chars long. At least 1
> digit.",
>             spec=spec(both(
>                         spec(equalwidget(form, 'passwd2'), 'not
> equal.'),
>                         spec(pattern('^\d|^\D+\d'), 'at least 1
> digit.'),
>                         spec(length(4, None), 'too short.')),
>                     'Password is not OK... ', 'Password is OK.'))


What would you think of having the widget itself, instead of the spec
handle the error messages for 1 level AND specifications like this?
I don't see any easy way to produce nice error messages from
any compound spec that is deeper.

What if the widget argument is a list
of (spec, error) pairs, all of which must be
satisfied by the value?

form.add_password('passwd1',
     specs=[(pattern('\d+$'), 'must be digits')
            (length(4), 'must have length 4')])



reply