EMF Validation on EAttributes [message #897573] |
Tue, 24 July 2012 10:47  |
Eclipse User |
|
|
|
Hi,
Is there any way to perform an EMF validation on individual EAttribute's of an EObject?
What I want to be able to do is to add an error message to a text field which represents the name of my EObject (which is an EAttribute of it) when that name is empty.
I can think of a way of doing it which would involve adding a constraint method to the overall EObject and setting the Diagnostic I create in that method's source value to be something which I can recognise in the UI and match it up but that seems wrong to me.
What I would really like is to be able to call something like validateName() on the field and for it to validate it for me in the same way that calling validate() on the entire model validates the model.
Any ideas?
Thanks,
Simon
|
|
|
|
|
|
Re: EMF Validation on EAttributes [message #897604 is a reply to message #897601] |
Tue, 24 July 2012 13:01  |
Eclipse User |
|
|
|
Simon,
Comments below.
On 24/07/2012 6:44 PM, Simon Barnett wrote:
> Just to add to my reply, I think I'd be right in saying that in order
> to validate a field which was bound to the name attribute (for
> instance) I'd then be validating the entire model every time, no?
For each constraint on an EClass, there is a generated method in the
validator that can you can call directly with the one instance object,
e.g., EcoreValidator.validateEClass_AtMostOneID. (Sorry it's a
metamodel example; hopefully that doesn't confuse the issue.)
> This would be the case for the validation of any given field for any
> given attribute - the entire model would be validated?
|
|
|
Powered by
FUDForum. Page generated in 0.24617 seconds