trying to understand how validation works in playframework1.2.4,I went through the docs and
also through some posts in SO..Still a couple of things nag me..
In the documentation ,the URICheck class has the following method
@Override
public void configure(URI uri) {
setMessage(uri.message());
this.schemes = Arrays.asList(uri.schemes());
}
where does the uri.schemes() come from?Is there a URI class apart from the @interface URI ?
Also,later in the isSatisfied() method,
public boolean isSatisfied(Object validatedObject, Object value,OValContext context, Validator validator){
...
}
The validatedObject is the instance of URI ,isn’t it? and the value parameter is the actual value passed which need to be validated.
If someone can clarify these,it would be much helpful..I hope there was a bit more in the javadocs explaining the parameters
The @interface URI doesn’t have any such methods.
I don’t see a URI class in the source code of PLay, only a URL, but the behaviour will be the same.
When you annotate a field with a validation-related annotation, you may give some parameters to that annotation. For example, to simplify:
That Annotation is defined as follows:
As you can see, it has 2 methods whose names are the same as the parameters I set. Once I call these methods, I’ll obtain the parameters related to that instance of the annotation.
Later on, Play does some “magic” via reflection to check the annotation related to a field of an entity, uses that instance in the configure method and then executes the isSatisfied method.
The configured method for
Maxis:As you can see, it uses the methods from the annotation, which you initialized in your entity.
I hope this helps 🙂