package com.community.pocket.util; import android.util.Patterns; import java.util.regex.Pattern; /** * 表单校验工具类 */ public class ValidUtil { /** * 校验邮箱 */ public static boolean emailValid(String email) { return Patterns.EMAIL_ADDRESS.matcher(email).matches(); } /** * 校验手机号 */ public static boolean mobilePhoneValid(String mobilePhone) { return Pattern.compile("^(13[0-9]|14[5|7]|15[0|1|2|3|5|6|7|8|9]|18[0|1|2|3|5|6|7|8|9])\\d{8}$").matcher(mobilePhone).matches(); } /** * 校验密码 */ public static boolean passwordvalid(String password) { return password != null && password.trim().length() > PropertiesUtil.getIntValue("password.length"); } /** * 校验用户名 */ public static boolean usernamevalid(String username) { return username != null && username.trim().length() > PropertiesUtil.getIntValue("username.length"); } /** * 校验验证码 */ public static boolean CAPTCHAValid(String code) { return Pattern.compile("^\\d{6}$").matcher(code).matches(); } }