μ κ· ννμ(보쑰μ λͺ©
* μΈμ μ°μ΄λκ°?
πκ°λ°μ νλ€λ³΄λ©΄, μ ν¨μ± κ²μ¦μ μν΄ μ κ· ννμμ μ¬μ©ν λκ° μλ€.
μ«μλ§ μ λ ₯, μλ¬Έμλ§ μ λ ₯, μ°λ½μ²μ '-' λ₯Ό ν¬ν¨νμ¬ μ λ ₯ λ±λ±.. μ νμ λκ³ μ ν λ μ¬μ©νλ€.
μ΄μ μμ£Ό μ°μ΄λ ννμμ 미리 λ§λ€μ΄λμ΄ κ³΅μ νκ³ μ νλ€.
μ κ· ννμ | μ€λͺ |
^[0-9]*$ | μ«μ |
^[a-zA-Z]*$ | μλ¬Έμ |
^[κ°-ν£]*$ | νκΈ |
\\w+@\\w+\\.\\w+(\\.\\w+)? | |
^\d{2,3}-\d{3,4}-\d{4}$ | μ νλ²νΈ |
^01(?:0|1|[6-9])-(?:\d{3}|\d{4})-\d{4}$ | ν΄λμ νλ²νΈ |
\d{6} \- [1-4]\d{6} | μ£Όλ―Όλ±λ‘λ²νΈ |
^\d{3}-\d{2}$ | μ°νΈλ²νΈ |
μμ± λ°©λ²μ μλμ κ°λ€.
#μ°λ½μ² μν
@Pattern(regexp = "^01(?:0|1|[6-9])-(?:\\d{3}|\\d{4})-\\d{4}$")
μ κ· ννμ μ€λͺ
^[0-9]*$ μ«μ
^[a-zA-Z]*$ μλ¬Έμ
^[κ°-ν£]*$ νκΈ
\\w+@\\w+\\.\\w+(\\.\\w+)? E-Mail
^\d{2,3}-\d{3,4}-\d{4}$ μ νλ²νΈ
^01(?:0|1|[6-9])-(?:\d{3}|\d{4})-\d{4}$ ν΄λμ νλ²νΈ
\d{6} \- [1-4]\d{6} μ£Όλ―Όλ±λ‘λ²νΈ
^\d{3}-\d{2}$ μ°νΈλ²νΈ
π¨π»π»β¨
@Data
public class SomeModel {
@ApiParam(defaultValue = "GIFT")
@NotEmpty(message = "λ°ν νμ
(type)μ νμ κ°μ
λλ€.")
private String type;
@Min(value = 0, message = "κΈμ‘μ 0μ μ΄μμ΄μ΄μΌ ν©λλ€.")
private long amount;
@ApiParam(defaultValue = "010-1234-1234")
//yyyy-mm-dd ννλ₯Ό κ°μ§λ ν¨ν΄ μ‘°μ¬
@Pattern(regexp = "^01(?:0|1|[6-9])-(?:\\d{3}|\\d{4})-\\d{4}$")
@NotEmpty(message = "'-'λ₯Ό ν¬ν¨ν μ°λ½μ²(Phone)λ νμ κ°μ
λλ€.")
private String phone;
}
λ°μν