I found nothing how to validate an Ecore model outside of Eclipse. Does someone know how to do this?
Run EMF Validation of an Ecore model outside of Eclipse
Asked Answered
Here is the skeleton of some code I've used to validate an EMF model outside of Eclipse:
EValidator.Registry.INSTANCE.put(YourPackage.eINSTANCE, new YourValidator());
BasicDiagnostic diagnostics = new BasicDiagnostic();
boolean valid = true;
for (EObject eo : yourResource.getContents()) {
Map<Object, Object> context = new HashMap<Object, Object>();
valid &= Diagnostician.INSTANCE.validate(eo, diagnostics, context);
}
There is more customization you can do, but I hope that helps get you started.
thanks for the answer. this validates the constraints defined. however, the constraint that an ID is unique throughout the document is not validated. do you have any leads on this? –
Chemotherapy
I don't know all the ins and outs of EMF validation, so take this as a guess. Perhaps you can put that constraint check into YourValidator. –
Pouched
© 2022 - 2024 — McMap. All rights reserved.