litesoft
@ 964
litesoft / trunk / GWT_Sandbox / FormEngine / src / com / temp / common / shared / validators / PhoneValidator.java
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
package com.temp.common.shared.validators; import org.litesoft.externalization.shared.*; import com.temp.common.shared.*; import com.temp.common.shared.utils.*; /** * Phone Number Validator, that requires at a minimum that a phone number not be * empty! * <p/> * This lame validation was copied from the Client utils.Util.java class. * * @author georgs */ public class PhoneValidator implements ValueValidator<String> { public enum ErrorTemplateIdCode { PhoneEmpty, // PhoneNoCtrlCharsAllowed } public static final PhoneValidator INSTANCE = new PhoneValidator(); protected PhoneValidator() { } public boolean isValid( String phone ) { return (null == checkValue( phone )); } @Override public E13nData checkValue( String phone ) { phone = StringUtils.noEmpty( phone ); if ( phone == null ) { return E13nData.builder( ErrorTemplateIdCode.PhoneEmpty ).build(); } int at = StringUtils.indexOfControlCharacter( phone ); if ( at != -1 ) { return E13nData.builder( ErrorTemplateIdCode.PhoneNoCtrlCharsAllowed ).build(); } return null; } } |
Commits for litesoft/trunk/GWT_Sandbox/FormEngine/src/com/temp/common/shared/validators/PhoneValidator.java
Revision | Author | Commited | Message |
---|---|---|---|
964 | GeorgeS | Fri 01 Aug, 2014 03:18:23 +0000 | ! |