Details

      Description

      An existing constraint can have several implementations of different types. The following commands will create two implementations of the Max constraints: one for type Number and one for String :

      constraint-new-validator --named MaxValidatorForNumber --type Number --targetConstraint Max
      constraint-new-validator --named MaxValidatorForString --type String --targetConstraint Max
      

      The generated code would look like this for Number :

      public class MaxValidatorForString implements ConstraintValidator<Max, Number> {
      
        @Override
        public void initialize(Max constraint) {
        }
      
        @Override
        public boolean isValid(Number value, ConstraintValidatorContext context) {
          return false;
        }
      }
      

      And like that for String :

      public class MaxValidatorForString implements ConstraintValidator<Max, String> {
      
        @Override
        public void initialize(Max constraint) {
        }
      
        @Override
        public boolean isValid(String value, ConstraintValidatorContext context) {
          return false;
        }
      }
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  Unassigned
                  Reporter:
                  agoncal Antonio Goncalves
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated: