cancel
Showing results for 
Search instead for 
Did you mean: 

Pattern Validation Constraint was not working for Integer attribute type

Former Member
0 Kudos

Hi all,

I am trying to apply Pattern constraint to an integer type through adminCockpit validation engine. I have used the ^[0-9]{1,5}$ regex to allow only numbers with in the mentioned range. I have reloaded the validation engine after creating the constraint. But getting an error as "No validator could be found for type: java.lang...", while i try to check the validation result for the specified attribute in Product Cockpit editor area.

Please help me out on this issue. Please find the attached screenshots for reference.

Thanks in advance

Regards,

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

You could check if the pattern validator works on a string field. If it does it is not applicable for integer and you might need to reimplement it for integer.

Former Member
0 Kudos

Hi Gubbacher,

thanks for response,

I have implemented the respective pattern constraints for String and Integer types. Its working fine with the String type. But not allowing for Integer type. I am using the Hybris 5.2 version. Is it version dependent?

Regards,

Former Member
0 Kudos

No, I don't think it's version dependent. I think that simply the pattern validator only works for String attributes and that you might need to implement one for Integer yourself.

Former Member
0 Kudos

Hi Konard, Same I have written my own ConstraintValidator validator with some business logic and it's work for perfectly work for Backoffice but not working for Impex imported from HAC I am using the Hybris 6.6 is there ant idea.

Thanks in advance...

Answers (1)

Answers (1)

former_member1010236
Participant
0 Kudos

I have very similar Problem. Getting "javax.validation.UnexpectedTypeException: HV000030: No validator could be found for type: java.lang.String."

The type I want to proofe is a localized String.

 @Target({ TYPE })
 @Retention(RUNTIME)
 @Constraint(validatedBy = YYYValidator.class)
 @Documented
 public @interface YYYConstraint {
 String message() default "    {...YYYConstraint.message}";

 Class<?>[] groups() default {};

 Class<? extends Payload>[] payload() default {};
 String qualifier();
 }

And the Validator looks line that:

 public class YYYValidator implements ConstraintValidator<YYYConstraint, ItemModel> {

 private String attribute;
 @Override
 public void initialize(YYYConstraint yyyConstraint) {

     attribute = yyyConstraint.qualifier();
 }

 @Override
 public boolean isValid(ItemModel itemModel, ConstraintValidatorContext constraintValidatorContext) {...}

Where do I have to specify the Type here in my Code??

Greatings David