[Zope3-checkins] CVS: Zope3/src/zope/app/interfaces/services - connection.py:1.5

Tres Seaver tseaver@zope.com
24 Apr 2003 11:30:23 -0400


On Thu, 2003-04-24 at 10:36, Guido van Rossum wrote:

> +
> +    name = TextLine(title=u"Name",
> +                    description=u"The name that is registered",
> +                    readonly=True,
> +                    required=True,
> +                    # XXX And yet, an empty name is accepted???
> +                    )

You can specify 'min_length=1' to prevent an empty name;  you could also
specify a regex to validate, e.g.:

    name = TextLine(title=u"Name",
                    description=u"The name that is registered",
                    readonly=True,
                    required=True,
                    constraint=re.compile(
                          r'^[a-zA-Z][a-zA-Z0-9_]*$').match
                    )

Tres.
-- 
===============================================================
Tres Seaver                                tseaver@zope.com
Zope Corporation      "Zope Dealers"       http://www.zope.com