[Bese-devel] Re: Forms validation and a possible patch.
Marco Baringer
mb at bese.it
Thu Jun 22 12:04:09 UTC 2006
Pupeno <pupeno at pupeno.com> writes:
> (flet ((push-message-unless-valid (field name)
> (multiple-value-bind (validp failed-validators)
> (validp field)
> (unless validp
> (dolist (failed-validator failed-validators)
> (push (list "error"
> (format nil "~A ~A" name
> (cond
> ((typep failed-validator 'not-empty-validator)
> "should not be empty.")
> ((typep failed-validator 'length-validator)
> (format nil "is too short. It should be at least ~a letters
> long." (min-length failed-validator)))
> (t "is not valid."))))
> (messages form)))))))
> (push-message-unless-valid (account-name form) "Your name")
> (push-message-unless-valid (account-email form) "Your email")
> (push-message-unless-valid (account-password form) "Your password")
applied somethnig along these lines.
> Basically the difference is that I don't print the class of the
> validator that failed but I dispatch on it generating a friendly message
> (the cond there).
nice idea, i'll apply something along these lines shortly
> The patch is attached.
applied. thanks.
--
-Marco
Ring the bells that still can ring.
Forget your perfect offering.
There is a crack in everything.
That's how the light gets in.
-Leonard Cohen
More information about the bese-devel
mailing list