Uploaded image for project: 'Hibernate Validator'
  1. HV-812

Make @Mod10Check and @Mod11Check constraints usable via API

    Details

    • Type: Task
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 5.1.0.Alpha1
    • Fix Version/s: 5.1.0.CR1
    • Component/s: engine
    • Labels:
      None
    • Last commented by a user?:
      true
    • Sprint:

      Description

      The constraints @Mod10Check and @Mod11Check should be usable via the API for programmatic constraint declaration.

      For each constraint we have a corresponding definition type which allows to configure that constraint via the API in a type-safe manner (actually it was missing for @ModCheck).

      We need Mod10CheckDef and Mod11CheckDef; E.g. @Mod11Check would then be used like this:

      HibernateValidatorConfiguration configuration = Validation
          .byProvider( HibernateValidator.class ).configure();
      
      ConstraintMapping constraintMapping = configuration.createConstraintMapping();
      
      constraintMapping
          .type( Book.class )
              .property( "isbn", FIELD )
                  .constraint( 
                      new Mod11CheckDef()
                          .multiplier( 10 )
                          .checkDigitPosition( 9 )
                          .endIndex( 9 )
                          .treatCheck10As( 'X' )
                  );
      
      Validator validator = configuration
          .addMapping( constraintMapping  )
          .buildValidatorFactory()
          .getValidator();     
      

        Attachments

          Issue links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: