All Downloads are FREE. Search and download functionalities are using the official Maven repository.

top.lingkang.finalvalidated.constraints.Email Maven / Gradle / Ivy

package top.lingkang.finalvalidated.constraints;

import java.lang.annotation.*;

/**
 * @author lingkang 
* created by 2024/1/28
* 注解的属性的值是否是邮箱
* 可自定义校验的表达式
* 默认返回 {字段名称} 不是邮箱格式 */ @Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) @Documented public @interface Email { /** * 邮箱校验的正则表达式,可自定义替换默认的表达式
* 校验邮箱的正则表达式
* 邮件,符合RFC 5322规范,正则来自:http://emailregex.com/
* What is the maximum length of a valid email address?
* 注意email 要宽松一点。
* 比如 [email protected][email protected][email protected][email protected]
* 宽松一点把,都算是正常的邮箱
*/ String value() default "(?:[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*|\"(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21\\x23-\\x5b\\x5d-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])*\")@(?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?|\\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:(?:[\\x01-\\x08\\x0b\\x0c\\x0e-\\x1f\\x21-\\x5a\\x53-\\x7f]|\\\\[\\x01-\\x09\\x0b\\x0c\\x0e-\\x7f])+)])"; /** * 校验失败时返回的消息,返回例示 message */ String message() default ""; /** * 校验失败时返回的消息,优先级比 message 高,返回例示 {tag} 不是邮箱格式 */ String tag() default ""; }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy