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
Solved! Go to Solution.
I tested your regex on a constraint in one of my models and saw the same problem you were seeing.
Try changing your regex to:
[a-zA-Z0-9]*
I tested that and it works.
I am confused because your error message is complaining about a property named membership_id which I do not see in the model you are sharing.
Hello Jeff Potts
Sorry for that, by mistake i posted different model.Below is the model i'm using
<?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>
I tested your regex on a constraint in one of my models and saw the same problem you were seeing.
Try changing your regex to:
[a-zA-Z0-9]*
I tested that and it works.
Thanks Jeff Potts, its working now.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.