无法正常工作Propel Match验证器(Cant do work Propel Match validators)
我正在开发一个CRUD应用程序。 我使用Propel作为ORM,并将验证规则添加到schema.xml中。 但是,这不行。 例如,我发送一个包含用户姓氏的字符串,验证器是:
<rule name='minLength' value='4'/> <rule name='maxLength' value='30'/> <rule name='notMatch' value='/^\s+$/' /> <!-- the name can be only chars and spaces --> <rule name='match' value='/[^A-Za-z ]$/'/>发送的用户姓氏是:'Martinez D Elia'。 第4条规则的有效失败。 任何想法 ?。
Im developing a CRUD application. I use Propel as ORM, and added validate rules into the schema.xml. But this, not work fine. For example, i send a string that contains a user lastname, and the validator is:
<rule name='minLength' value='4'/> <rule name='maxLength' value='30'/> <rule name='notMatch' value='/^\s+$/' /> <!-- the name can be only chars and spaces --> <rule name='match' value='/[^A-Za-z ]$/'/>The user lastname sent was: 'Martinez D Elia'. And the valid fails on 4th rule. Any idea ?.
最满意答案
稍微更改上一个答案,因为您希望至少4个字符,最多30个字符,您可能想要使用此:
/^[A-Za-z ]{4,30}$/另请注意,在正则表达式之前和之后确实需要“/”。 还有,你的正则表达式错了两个原因:在字符类中放置“^”和在字符类之后放置缺少的长度限定符(没有“*”,“+”或括号{},你只匹配一个字符,任何更多都会失败)。
The regex is wrong. The correct match is:
^[A-Za-z ]*$更多推荐
发布评论