/* Private String username; the user name cannot be blank, and it must be a 3-8 character abcdABcdprivate String password; the password cannot be blank, and it must be a 3-8 number private String password2; the two passwords must be consistent with the private String email; they can be empty. If they are not empty, they must be a valid mailbox private String birthday. If they are not empty, if a valid date **/public boolean validate () {boolean isOk = true; if (this. username = null | this. username. trim (). equals ("") {isOk = false; errors. put ("username", "user name cannot be blank !! ");} Else {if (! This. username. matches ("[a-zA-Z] {3, 8}") {isOk = false; errors. put ("username", "the user name must be 3-8 letters !! ") ;}} If (this. password = null | this. password. trim (). equals ("") {isOk = false; errors. put ("password", "the password cannot be blank !! ");} Else {if (! This. password. matches ("\ d {3, 8}") {isOk = false; errors. put ("password", "the password must be a 3-8 digit number !! ") ;}// Private String password2; the two passwords must be consistent if (this. password2! = Null) {if (! This. password2.equals (this. password) {isOk = false; errors. put ("password2", "The two passwords are inconsistent !! ") ;}} // Private String email; it can be blank. if it is not blank, it is a legal email if (this. email! = Null) {// the email address Regular Expression if (! This. email. matches ("^ ([a-z0-9A-Z] + [-| \.]?) + [A-z0-9A-Z] @ ([a-z0-9A-Z] + (-[a-z0-9A-Z] + )? \\.) + [A-zA-Z] {2,} $ ") {isOk = false; errors. put ("email", "email is not a legal email !! ") ;}} // The regular expression of the mobile phone number is ^ (13 [0-9]) | (15 [^ 4, \ D]) | (18 [-9]) \ d {8} $ // private String birthday; it can be blank, if a valid date if (this. birthday! = Null) {try {DateLocaleConverter conver = new DateLocaleConverter (); conver. convert (this. birthday);} catch (Exception e) {isOk = false; errors. put ("birthday", "birthday must be a date !! ") ;}} Return isOk ;}