Sunday, 15 September 2013

Spring Validation with Groups in Domain Objects with Builder Pattern

Spring Validation with Groups in Domain Objects with Builder Pattern

I am writing some help code to add builders to my domain model using the
Builder Pattern. I have the basic portion of the code built, but I want to
added another build method that will validate the newly built object. I
envision this new method would accept a class to match up with the groups
in my bean validation. Therefore, when I get the object back from the
builder I know it is a valid abject for the state I want. I have two
questions concerning this approach.
First, does this sound like a good approach? I have not seen anything on
the net about doing this, but I think it would be a good idea to have in a
builder.
Next question, What is a good way to get a validator into the builder?
Should I try to auotwire it in or something else?

No comments:

Post a Comment