[Bese-devel] Re: Small form patch
Vladimir Sekissov
svg at surnet.ru
Sat Dec 3 15:49:49 UTC 2005
Good day,
> Meanwhile I wonder how I can pass arguments to the constraints.
> I got two scenarios:
> I'd like the user to type in a password, and repeat it and then check
> that they match. So I'd like a :equal-to 'password, but I haven't
> figured out how to pass an argument to the constraint function.
>
> Another scenario is that I want a :unique 'table 'column check that
> looks up in my database. Again, I need to pass arguments to the
> function.
There are two ways probably.
- from constraint function:
(defun my-passwd-constraint (value-first element)
(let* ((form (parent element))
;; we don't know the order of elements in the form
;; get value directly
(value-second (read-client-value (password-second form))))
(unless (equal value-second value-first)
(signal-ie-constraint-violation ...))))
- from form/composite VALIDATE-VALUE method:
(defmethod validate-value :after ((f my-form) slot-alist &key &allow-other-keys)
(when (not (equal (cdr (assoc 'password slot-alist))
(cdr (assoc 'password-second slot-alist))))
(report-error f 'password "Don't mutch")
(push 'password (invalid-slots f))))
The second case is probably relevant to the first.
Best Regards,
Vladimir Sekissov
More information about the bese-devel
mailing list