Custom validation for ID attribute [message #1386504] |
Tue, 17 June 2014 20:02  |
Eclipse User |
|
|
|
Hi everyone,
I am trying to customize the validation for every ID attribute (of every EClass) but I couldn't find the correct way to do it. I need this in order to validate the use of illegal characters like "$", "&", " " or "#".
Class A
Att1 : ID = true
Att2 : ID = false
Class B
Att3 : ID = true
Att4 : ID = false
In the above example, Att1 (Class A) and Att3 (Class B) should be validated with the custom validator.
Is this possible to do? Or anyone knows any way to do this or a better approach than custom validation?
Thanks in advance!
|
|
|
|
|
|
|
Re: Custom validation for ID attribute [message #1387088 is a reply to message #1387075] |
Tue, 24 June 2014 00:58  |
Eclipse User |
|
|
|
Agustin,
The pattern annotation is quite useful. Thanks for sharing your results.
On 24/06/2014 12:58 AM, Agustin Vosou wrote:
> After testing the ID EDataType from XMLType.ecore and it's
> constraints, I decided to go for the first option Ed gave me... So
> I've defined the following EDataType:
>
>
> <eClassifiers xsi:type="ecore:EDataType" name="ID"
> instanceClassName="java.lang.String">
> <eAnnotations
> source="http:///org/eclipse/emf/ecore/util/ExtendedMetaData">
> <details key="name" value="ID"/>
> <details key="baseType" value="java.lang.String"/>
> <details key="pattern" value="[a-zA-Z0-9]+"/>
> </eAnnotations>
> </eClassifiers>
>
>
> As you can see, I've used an ExtendedMetadata annotation to define the
> accepted values with a pattern.
>
> Thank you very much for your help and time.
>
> Regards,
> Agustin.
|
|
|
Powered by
FUDForum. Page generated in 0.28108 seconds