Question: I want to implement a custom validator class. There are some tutorials out in the internet e.g. <http://blog.swwomm.com/2011/02/custom-grails-constraints.html> In these tutorials is described that you must register the validator class in the Config.groovy

The problem is that the Config.groovy is replaced by the application.groovy in Grails 3. My application.groovy looks like this:

```
import at.byte_code.businessSuite.core.NamespaceValidatorConstraint
import grails.validation.ConstrainedProperty

ConstrainedProperty.removeConstraint(ConstrainedProperty.VALIDATOR_CONSTRAINT)
ConstrainedProperty.registerNewConstraint(ConstrainedProperty.VALIDATOR_CONSTRAINT, NamespaceValidatorConstraint.class)

```

But when I try to run the app i get the following error:

```
| Error Error occurred running Grails CLI: startup failed:
script1481056327870569414787.groovy: 1: unable to resolve class at.byte_code.businessSuite.core.NamespaceValidatorConstraint
 @ line 1, column 1.
   import at.byte_code.businessSuite.core.NamespaceValidatorConstraint
   ^

script1481056327870569414787.groovy: 2: unable to resolve class grails.validation.ConstrainedProperty
 @ line 2, column 1.
   import grails.validation.ConstrainedProperty
   ^

```

How can I register my custom validator class?

Answer: 
This is due to the fact that in Grails 3 it is forbidden to import third-party classes in application.groovy. To use third-party classes, create a runtime.groovy file.
One solution (maybe there are others) was to add this code to the Application class itself:

```
class Application extends GrailsAutoConfiguration {

    static void main(String[] args) {
        GrailsApp.run(Application, args)
    }

    void doWithApplicationContext() {
        ConstrainedProperty.removeConstraint(ConstrainedProperty.VALIDATOR_CONSTRAINT)
        ConstrainedProperty.registerNewConstraint(ConstrainedProperty.VALIDATOR_CONSTRAINT, NamespaceValidatorConstraint.class)
    }
}

```