Uploaded image for project: 'Forge'
  1. Forge
  2. FORGE-1926 Adding more commands to Forge and improve existing ones
  3. FORGE-1618

Command constraint-new-validator to create a new validator implementation

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Unresolved
    • Icon: Major Major
    • 3.x Future
    • 2.1.1.Final
    • Java EE

      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;
        }
      }
      

              Unassigned Unassigned
              agoncal Antonio Goncalves (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated: