[Error resolution] HV000030: No validator could be found for constraint ~ ~

【environment】
[Timing of encounter]

--Under development of app with spring-boot


Conclusion

--You made a mistake in the annotation you should use.

Cause

Validation was set in a way that cannot be used with @Pattern.


【error contents】
There was an unexpected error (type=Internal Server Error, status=500).
HV000030: No validator could be found for constraint 'javax.validation.constraints.Pattern' validating type 'java.math.BigDecimal'. Check configuration for 'price'

Translation:

HV000030:Mold'java.math.BigDecimal'Constraints to verify
'javax.validation.constraints.Pattern'The validator was not found. price'Check the configuration of.

Wrong


//Required input, 1000 yen or more, convert to numerical value
@NotNull
@Min(1000)
@Pattern(regexp = "#,###") //Convert the character string of the specified pattern to a numerical value
private BigDecimal price;

Positive

//Required input, 1000 yen or more, convert to numerical value
@NotNull
@Min(1000)
@NumberFormat(pattern = "#,###") //Convert the character string of the specified pattern to a numerical value
private BigDecimal price;

Recommended Posts

[Error resolution] HV000030: No validator could be found for constraint ~ ~
Error: Main class not found or could not be loaded
ERROR! MySQL server PID file could not be found!
RestTemplate Could not extract response: no suitable HttpMessageConverter found for response type countermeasures