我想为字段添加验证,该字段应检查字符串是否包含" .html"在它的最后。请参阅下面的配置: http://screencast.com/t/YgBIKcyU71SQ
但验证不起作用。似乎我的对话框配置不正确。你能帮我弄清楚错误在哪里吗?
提前致谢
答案 0 :(得分:1)
您的模式为.html$
这很可能是不正确的。它应该是相反的:^\.html$
HTH, 扬
答案 1 :(得分:0)
如果您想使用info.magnolia.ui.form.validator.definition.RegexpValidatorDefinition
:
在此之前,您要确保正则表达式是正确的
添加field validation configuration as described in the Magnolia CMS documentation。
这就是我的验证所做的:Only characters allowed (without the quotes): "a" to "z" (no accents/diacritics allowed & only lower case), "0" to "9", ".", "_", "-".
使用的正则表达式模式:[a-z0-9._-]+
随意在regexplanet.com/advanced/java/index.html
上进行测试在下面找到"验证器"节点配置。将其保存为xml文件&导入它。
<?xml version="1.0" encoding="UTF-8"?>
<sv:node sv:name="validators" xmlns:sv="http://www.jcp.org/jcr/sv/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>mgnl:contentNode</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>112b96c1-b942-4657-9541-f8776c74d68d</sv:value>
</sv:property>
<sv:property sv:name="jcr:createdBy" sv:type="String">
<sv:value>admin</sv:value>
</sv:property>
<sv:property sv:name="mgnl:created" sv:type="Date">
<sv:value>2016-11-17T19:26:09.240+01:00</sv:value>
</sv:property>
<sv:property sv:name="mgnl:createdBy" sv:type="String">
<sv:value>superuser</sv:value>
</sv:property>
<sv:property sv:name="mgnl:lastModified" sv:type="Date">
<sv:value>2016-11-17T19:26:41.771+01:00</sv:value>
</sv:property>
<sv:property sv:name="mgnl:lastModifiedBy" sv:type="String">
<sv:value>superuser</sv:value>
</sv:property>
<sv:node sv:name="urlCharacters">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>mgnl:contentNode</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>4d52be80-7211-44d4-8d0a-53a50aed9bc9</sv:value>
</sv:property>
<sv:property sv:name="class" sv:type="String">
<sv:value>info.magnolia.ui.form.validator.definition.RegexpValidatorDefinition</sv:value>
</sv:property>
<sv:property sv:name="errorMessage" sv:type="String">
<sv:value>Only characters allowed (without the quotes): "a" to "z" (without accents), "0" to "9", ".", "_", "-". And only lower case.</sv:value>
</sv:property>
<sv:property sv:name="jcr:createdBy" sv:type="String">
<sv:value>admin</sv:value>
</sv:property>
<sv:property sv:name="mgnl:created" sv:type="Date">
<sv:value>2016-11-17T19:26:41.772+01:00</sv:value>
</sv:property>
<sv:property sv:name="mgnl:createdBy" sv:type="String">
<sv:value>superuser</sv:value>
</sv:property>
<sv:property sv:name="mgnl:lastModified" sv:type="Date">
<sv:value>2016-11-18T11:30:51.883+01:00</sv:value>
</sv:property>
<sv:property sv:name="mgnl:lastModifiedBy" sv:type="String">
<sv:value>superuser</sv:value>
</sv:property>
<sv:property sv:name="pattern" sv:type="String">
<sv:value>[a-z0-9._-]+</sv:value>
</sv:property>
</sv:node>
</sv:node>