[Zope3-dev] field validation in edit form

Garrett Smith garrett@mojave-corp.com
Sat, 12 Jul 2003 19:18:42 -0500


Richard Jones wrote:
> On Sunday, July 13, 2003, at 07:03  AM, Garrett Smith wrote:
>> Brad Bollenbach wrote:
>>> Your suggestion to make this configurable may or may not remain
>>> useful, depending on whether or not the current behaviour would be
>>> considered to be Doing The Right Thing.
>>=20
>> Not sure what you mean here. I would expect the edit form to complain
>> about missing required fields. Perhaps the Right Thing here is to
>> simply set strict to true?
>=20
> The other thing to remember here is that required is a minimalist
> sorta concept in Widget land. If a field is required, then you're
> just saying there must be some value for the field, even if it's an
> "empty" value (ie. an empty string or similar). If you wish to make a
> text widget be non-empty, then you need to enforce a min_length
> constraint.=20

Strings present a problem in HTML forms, since there's no way of making
them None. But I'm talking about Ints  -- the IntWidget is setup to
return None when an int isn't specified in the text field. Currently,
such fields can be omitted even when they're required.

Setting strict to True would fix this.

I agree -- required strings can be empty, but, as you say, min_length
can be used here.

 -- Garrett