このコンテンツは選択した言語では利用できません。

1.2. Built in constraints


Hibernate Validator comes with some built-in constraints, which covers most basic data checks. As we'll see later, you're not limited to them, you can literally in a minute write your own constraints.
Expand
Table 1.1. Built-in constraints
Annotation Apply on Runtime checking Hibernate Metadata impact
@Length(min=, max=) property (String) check if the string length match the range Column length will be set to max
@Max(value=) property (numeric or string representation of a numeric) check if the value is less than or equals to max Add a check constraint on the column
@Min(value=) property (numeric or string representation of a numeric) check if the value is more than or equals to min Add a check constraint on the column
@NotNull property check if the value is not null Column(s) are not null
@NotEmpty property check if the string is not null nor empty. Check if the connection is not null nor empty Column(s) are not null (for String)
@Past property (date or calendar) check if the date is in the past Add a check constraint on the column
@Future property (date or calendar) check if the date is in the future none
@Pattern(regex="regexp", flag=) or @Patterns( {@Pattern(...)} ) property (string) check if the property match the regular expression given a match flag (see java.util.regex.Pattern ) none
@Range(min=, max=) property (numeric or string representation of a numeric) check if the value is between min and max (included) Add a check constraint on the column
@Size(min=, max=) property (array, collection, map) check if the element size is between min and max (included) none
@AssertFalse property check that the method evaluates to false (useful for constraints expressed in code rather than annotations) none
@AssertTrue property check that the method evaluates to true (useful for constraints expressed in code rather than annotations) none
@Valid property (object) perform validation recursively on the associated object. If the object is a Collection or an array, the elements are validated recursively. If the object is a Map, the value elements are validated recursively. none
@Email property (String) check whether the string is conform to the email address specification none
@CreditCardNumber property (String) check whether the string is a well formated credit card number (derivative of the Luhn algorithm) none
@Digits(integerDigits=1) property (numeric or string representation of a numeric) check whether the property is a number having up to integerDigits integer digits and fractionalDigits fractonal digits define column precision and scale
@EAN property (string) check whether the string is a properly formated EAN or UPC-A code none
Red Hat logoGithubredditYoutubeTwitter

詳細情報

試用、購入および販売

コミュニティー

Red Hat ドキュメントについて

Red Hat をお使いのお客様が、信頼できるコンテンツが含まれている製品やサービスを活用することで、イノベーションを行い、目標を達成できるようにします。 最新の更新を見る.

多様性を受け入れるオープンソースの強化

Red Hat では、コード、ドキュメント、Web プロパティーにおける配慮に欠ける用語の置き換えに取り組んでいます。このような変更は、段階的に実施される予定です。詳細情報: Red Hat ブログ.

会社概要

Red Hat は、企業がコアとなるデータセンターからネットワークエッジに至るまで、各種プラットフォームや環境全体で作業を簡素化できるように、強化されたソリューションを提供しています。

Theme

© 2026 Red Hat
トップに戻る