[hibernate-dev] [Bean Validation] Adding interpolation facilities

Emmanuel Bernard emmanuel at hibernate.org
Sat Mar 7 18:52:49 EST 2009


What do you think of
public class ConstraintValidatorContext {
     addInterpolatedParameter(String name, String value);
}

public class SyntaxValidator implements ConstraintValidator<Syntax,  
String> {
     public boolean isValid(String value, ConstraintValidatorContext  
context) {
         detectedSyntax = ...;
         context.addInterpolatedParameter("detectedSyntax",  
detextedSyntax);
         return allowedSyntaxes.contains(detectedSyntax);
     }
}

@Syntax(value={JAVA, HTML}, message="{constraint.syntax}")
String text;

ValidatorMessage_en.properties
constraint.syntax=Unable to support {detectedSyntax}


=>
"Unable to support PHP"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/hibernate-dev/attachments/20090307/7f9be2be/attachment.html 


More information about the hibernate-dev mailing list