AnsweredAssumed Answered

Regular Expression Issue in constraints Tag when using custom model

Question asked by ajay.k on Oct 30, 2018
Latest reply on Nov 5, 2018 by ajay.k

Hello,

                     I created custom model to apply for uploaded documents in alfresco share. My customModel.xml has constraints as

below:

 

 

<?xml version="1.0" encoding="UTF-8"?>

<model name="t:membershipdocumentsmodel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

<!-- Optional meta-data about the model -->
<description>Membership Document Model</description>
<author>Techsophy</author>
<version>1.0</version>

<!-- Imports are required to allow references to definitions in other models -->
<imports>
<!-- Import Alfresco Dictionary Definitions -->
<import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d" />
<!-- Import Alfresco Content Domain Model Definitions -->
<import uri="http://www.alfresco.org/model/content/1.0" prefix="cm" />
<import uri="http://www.alfresco.org/model/system/1.0" prefix="sys"/> 
</imports>

<namespaces>
<namespace uri="http://www.tech.com/model/content/1.0" prefix="t" />
</namespaces>

 

<constraints>
<constraint name="t:alphanumeric" type="REGEX">
<parameter name="expression">
<value>[a-zA-Z0-9]</value>
</parameter>
<parameter name='requiresMatch'><value>true</value></parameter>
</constraint>
<constraint name="t:length" type="LENGTH">
<parameter name='minLength'><value>1</value></parameter>
<parameter name='maxLength'><value>10</value></parameter>
</constraint>
</constraints>

 

<types>
<!-- Enterprise-wide generic document type -->
<type name="t:membership_doc">
<title>Transaction Document</title>
<parent>cm:content</parent>
<properties>
<property name="t:membership_id">
<type>d:text</type>
<mandatory>true</mandatory>
<constraints>
<constraint ref="t:alphanumeric" />
<constraint ref="t:length" />
</constraints>
</property>
</properties>
</type>
</types>

 

</model>

 

 

My goal is to allow only alphanumeric characters but for above regular expression it is showing failure message

 

And it is allowing the special characters which i won't need.

Is there any mistake in my approach?

 

 

Thanks & Regards

Ajay

Outcomes