Package org.hibernate.validator.constraintvalidation

Examples of org.hibernate.validator.constraintvalidation.HibernateConstraintValidatorContext


    public void initialize(OracleConstraint constraintAnnotation) {
    }

    @Override
    public boolean isValid(String question, ConstraintValidatorContext context) {
      HibernateConstraintValidatorContext hibernateContext = context.unwrap( HibernateConstraintValidatorContext.class );


      if ( question.equals( QUESTION_1 ) ) {
        createSingleConstraintViolation( hibernateContext );
      }
      else if ( question.equals( QUESTION_2 ) ) {
        createMultipleConstraintViolationsUpdatingVariableValues( hibernateContext );
      }
      else if ( question.equals( QUESTION_3 ) ) {
        hibernateContext.addExpressionVariable( "answer", "${foo}" );
      }
      else {
        tryingToIllegallyUseNullAttributeName( hibernateContext );
      }
View Full Code Here


  public boolean isValid(Date value, ConstraintValidatorContext context) {
    Date now = GregorianCalendar.getInstance().getTime();

    if ( value.before( now ) ) {
      HibernateConstraintValidatorContext hibernateContext =
          context.unwrap( HibernateConstraintValidatorContext.class );

      hibernateContext.disableDefaultConstraintViolation();
      hibernateContext.addExpressionVariable( "now", now )
          .buildConstraintViolationWithTemplate( "Must be after ${now}" )
          .addConstraintViolation();

      return false;
    }
View Full Code Here

TOP

Related Classes of org.hibernate.validator.constraintvalidation.HibernateConstraintValidatorContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.