无法正常工作Propel Match验证器(Cant do work Propel Match validators)

编程入门 行业动态 更新时间:2024-10-27 13:31:03
无法正常工作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 ]*$

更多推荐

本文发布于:2023-08-01 20:56:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1365714.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:无法正常   工作   Propel   validators   work

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!