Validator in generic REST API


i would like to know what’s your opinion on how to do validation on the REST API layer.
Let’s imagine i’ve a Class customer that has a telephone number which should be a valid telephone number. In the UI layer i’d create a Class that

implements Field.Validator

, but how do i do this in case of the generic API usage?

I could imagine something like using an Entity Listener or use the feature to call services via the API and not use the Entity API layer at all. Interesting for me would be to see what’s your take on that to get a maximal code reuse?


Hi Mario,
We plan to start working on using the Bean Validation for validating entities fields both in the new REST API and in the UI. So you will be able to define constraints in the entity code and then they will be used everywhere. We’re not sure that we’ll be able to finish this work in release 6.3, but we’ll definitely implement it in 6.4

1 Like

Hi Max,

this sounds like a very solid solution to this problem. Does that mean that the Field.Validator interface will be replaced by Bean Validation?

When you talk about it, can you elaborate a little bit on how the integration with Spring will be? As i know from Grails-Land Spring has a Integration with JSR-303 which is fairly cool. Or are you planning to go straight to the JSR standard and stay on the non-spring-specific parts? An example that comes to my mind is that javax.inject.Inject is used for DI instead of org.springframework.bean.factory.Autowired directly (but Spring as the execution engine for this in both cases).

When you say perhaps in 6.3 - does this mean it’s already implemented or do you plan to make changes like this from RC1 (which is out now) to the actual release?


We just started doing the research so I can’t tell you whether we will replace the Field.Validator or not and definitely answer you questions about implementation details. Most likely, this changes will appear in the 6.4.