Skip to content

Instantly share code, notes, and snippets.

@AndSky90
Created November 16, 2019 13:31
Show Gist options
  • Save AndSky90/a2b929154f820cda0574206d81fc7d52 to your computer and use it in GitHub Desktop.
Save AndSky90/a2b929154f820cda0574206d81fc7d52 to your computer and use it in GitHub Desktop.
Validator types regex patterns
/**перечисление типов валидатора текста*/
enum class ValidatorType(
val regex: Pattern
) {
VALIDATE_NAME(Pattern.compile("^[а-яА-ЯёЁa-zA-Z_ -]+$")),
VALIDATE_EMAIL(Patterns.EMAIL_ADDRESS),
VALIDATE_WEB_URL(Patterns.WEB_URL),
VALIDATE_POSITION(Pattern.compile("^[а-яА-ЯёЁa-z0-9A-Z_ -]*$")),
ANY(Pattern.compile(".*")),
VALIDATE_DATE(Pattern.compile("^(0?[1-9]|[12][0-9]|3[01])[.](0?[1-9]|1[012])[.]\\d{4}\$")),
VALIDATE_ARABIC_NUMBER(Pattern.compile("^[0-9]+$")),
VALIDATE_PHONE_NUMBER(Pattern.compile("^\\s*(?:\\+?(\\d{1,3}))?([-. (]*(\\d{3})[-. )]*)?((\\d{3})[-. ]*(\\d{2,4})(?:[-.x ]*(\\d+))?)\\s*\$"))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment