13.07.2015 Views

JSR 303 的参考实现使用指南 - JBoss

JSR 303 的参考实现使用指南 - JBoss

JSR 303 的参考实现使用指南 - JBoss

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

第 2 章 Validation step by step表 2.3. Custom constraints provided by Hibernate ValidatorAnnotationSupported data作 用Hibernate metadatatypesimpact@CreditCardNumber String Checks thatthe annotatedstring passesthe Luhn checksumtest. Note, thisvalidation aimsto check foruser mistakes,not credit cardvalidity! Seealso Anatomyof Credit CardNumbers [http://www.merriampark.com/anatomycc.htm].@Email String Checks whether thespecified stringis a valid emailaddress.没 有没 有@Length(min=, max=) StringValidates that theannotated string isbetween min and maxincluded.对 应 的 数 据 库 表 字 段的 长 度 会 被 设 置 成 约束 中 定 义 的 最 大 值 .@NotBlank String Checks that theannotated stringis not null andthe trimmed lengthis greater than 0.The difference to@NotEmpty is thatthis constraintcan only be appliedon strings andthat trailingwhitespaces areignored.没 有@NotEmptyString, Collection,Checks whether the没 有Map and arraysannotated element26

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!