10-30-2018 07:35 AM
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
11-02-2018 08:42 PM
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.
10-30-2018 02:16 PM
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.
10-30-2018 10:18 PM
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>
11-02-2018 08:42 PM
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.
11-05-2018 07:05 AM
Thanks Jeff Potts, its working now.
Explore our Alfresco products with the links below. Use labels to filter content by product module.