Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hibernate validator error Spring boot

I'm getting:

javax.validation.ValidationException: HV000032: Unable to initialize org.hibernate.validator.internal.constraintvalidators.bv.PatternValidator

My pom.xml:

<dependency>
    <groupId>javax.validation</groupId>
    <artifactId>validation-api</artifactId>
    <version>1.1.0.Final</version>
</dependency>

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-validator</artifactId>
    <version>5.2.2.Final</version>
</dependency>

No other error is showing, even with debug-mode logging.

@Pattern(regexp = "[0-9.- ]*"); here is the code
like image 609
Imtiaz Mirza Avatar asked Dec 17 '15 20:12

Imtiaz Mirza


2 Answers

The error you are getting is due to your regexp being invalid. To solve it you need change your regexp to something really basic:

@Pattern(regexp = "[0-9]*");

Then gradually add the extra characters to spot what is causing the error. It could be two dashes or the space, but you can easily test it.

like image 182
Gergely Bacso Avatar answered Sep 18 '22 12:09

Gergely Bacso


The issue with your regexp here is with dash used inside of it. Put dash at the beginning:

@Pattern(regexp = "[-0-9. ]*");
like image 25
heroin Avatar answered Sep 18 '22 12:09

heroin