3
0

More than 3 years have passed since last update.

【エラー解決】HV000030: No validator could be found for constraint 〜〜

Last updated at Posted at 2020-08-17
【環境】
  • ProductName: Mac OS X
  • ProductVersion: 10.14.6
  • BuildVersion: 18G2022
【遭遇したタイミング】
  • spring-bootでアプリを開発中

結論

  • 使うべきアノテーションを間違えていた。

原因

@Pattern では使えない方法でバリデーションを設定していた。


【エラー内容】
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'

訳:

HV000030: 型 'java.math.BigDecimal' を検証する制約 
'javax.validation.constraints.Pattern' のバリデータが見つかりませんでした。price' の構成を確認してください。


// 必須入力、1000円以上、数値へ変換
@NotNull
@Min(1000)
@Pattern(regexp = "#,###") // 指定パターンの文字列を、数値に変換する
private BigDecimal price;

// 必須入力、1000円以上、数値へ変換
@NotNull
@Min(1000)
@NumberFormat(pattern = "#,###") // 指定パターンの文字列を、数値に変換する
private BigDecimal price;
3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0