0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Java】BeanValidationでURL形式をチェックする場合HibernateValidatorの@URLは使わない方がよいかもしれない

Last updated at Posted at 2020-02-05

内容は大体タイトルの通りです。

理由

org.hibernate.validator.internal.constraintvalidators.hv.URLValidatorの実装では「http:」と入力しただけの状態でもバリデーションが通ってしまいます。
「入力される内容はhttp/httpsといったプロトコルだけ、最低限ドメインまで入っていてほしい」など、URLはURLでも限られた内容しか入力されない場合は@Patternアノテーションを使って正規表現でチェックした方が良いでしょう。

補足

Maven Repository: org.hibernate.validator » hibernate-validator » 6.1.2.Finalで検証しました。

0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?