6

I found nothing how to validate an Ecore model outside of Eclipse. Does someone know how to do this?

Lii
  • 11,553
  • 8
  • 64
  • 88
Dr. Simon Harrer
  • 1,954
  • 1
  • 15
  • 26

1 Answers1

4

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.

Lii
  • 11,553
  • 8
  • 64
  • 88
ChrisH
  • 4,788
  • 26
  • 35
  • 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? – Dr. Simon Harrer Sep 08 '10 at 15:40
  • 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. – ChrisH Sep 08 '10 at 18:20