I've implemented the following rules in my Xtext DSL:

```
House:
    'House' name=ID
    description=STRING?
    ('height' height=DOUBLE heightUnit=UNIT)? &
    ('width' width=DOUBLE widthUnit=UNIT)? &
    'end' 'House' 
    ;

enum UNIT:
        m = 'm' |
        cm = 'cm'
    ;

```

It allows me to define the following, using the editor based on that DSL:

```
House MyHouse
    "This is my house"
    height 15.5 m
    width 3000.2 cm
end MyHouse

```

How can I validate the units, defined by the user? For example, both height and width should have the unit *m* and if the user defines something different (*cm* for example), the editor should show an error.

I've checked [this](http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.xtext.doc%2Fcontents%2F030-tutorial-next-steps.html) site, which describes how to create validation rules, but where do I have to register them, so that they can work perperly?

**UPDATE:** As described in Ravens comment under his post, I've used reverse engineering and added the correspondig package and class, which now looks like the following:

```
package com.language.validation

import com.language.mylanguage.House
import org.eclipse.xtext.validation.Check

class MylanguageValidator {

    @Check
    def unitCheck(House house) {
        val hWidth = house.width

        if (hWidth != null) {
            if (!hWidth.equals("m")) {
                val errorMsg = "House width must be defined in m";
                // error method undefined
            }
        }
    }
}

```

The Package of the class is inside the plug-in project `com.language.mylanguage`. I am trying to validate, if the user used *m* as the unit. If not, an error message should appear. The method `error()` is undefined. Do I have to import or extend another class?