Validation best practices [message #1490960] |
Fri, 28 November 2014 15:41 |
Hauke Fuhrmann Messages: 333 Registered: July 2009 |
Senior Member |
|
|
Hi there,
does anyone have best practices for doing *simple* validation rules for
EMF ecore models?
I tried using the "constraints" EAnnotation which generates an empty
validation method that has to be implemented in Java.
First, this is quite effort prone, compared for example to restrictions
to simple types in an XSD.
Second, I have many data types that are restricted in the same way, e.g.
an integer that may have a value between 0 and 63 where a generic error
message would be sufficient. The generated validation methods, however,
have to be implemented for every class again, so I cannot reuse the same
validation method.
Any best practices? Or is the question too general?
Cheers,
Hauke
|
|
|
|
Re: Validation best practices [message #1494164 is a reply to message #1490960] |
Mon, 01 December 2014 08:29 |
Ed Merks Messages: 33113 Registered: July 2009 |
Senior Member |
|
|
Hauke,
The constraints generated for XSD are driven by extended metadata
annotations (facets), so you could use those same annotations on your
own model.
On 28/11/2014 4:41 PM, Hauke Fuhrmann wrote:
> Hi there,
>
> does anyone have best practices for doing *simple* validation rules
> for EMF ecore models?
>
> I tried using the "constraints" EAnnotation which generates an empty
> validation method that has to be implemented in Java.
>
> First, this is quite effort prone, compared for example to
> restrictions to simple types in an XSD.
>
> Second, I have many data types that are restricted in the same way,
> e.g. an integer that may have a value between 0 and 63 where a generic
> error message would be sufficient. The generated validation methods,
> however, have to be implemented for every class again, so I cannot
> reuse the same validation method.
>
> Any best practices? Or is the question too general?
>
> Cheers,
> Hauke
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03685 seconds