Java Code Examples for org.apache.commons.validator.GenericValidator#isEmail()
The following examples show how to use
org.apache.commons.validator.GenericValidator#isEmail() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmailValidator.java From hop with Apache License 2.0 | 5 votes |
public boolean validate( ICheckResultSource source, String propertyName, List<ICheckResult> remarks, ValidatorContext context ) { String value = null; value = ValidatorUtils.getValueAsString( source, propertyName ); if ( !GenericValidator.isBlankOrNull( value ) && !GenericValidator.isEmail( value ) ) { ActionValidatorUtils.addFailureRemark( source, propertyName, VALIDATOR_NAME, remarks, ActionValidatorUtils.getLevelOnFail( context, VALIDATOR_NAME ) ); return false; } else { return true; } }
Example 2
Source File: LangChecker.java From Asqatasun with GNU Affero General Public License v3.0 | 5 votes |
/** * * @param extractedText * @return */ protected boolean isTextTestable(String extractedText) { if (StringUtils.isBlank(extractedText)){ return false; } String textToTest = StringUtils.trim(extractedText); Matcher m = nonAlphanumericPattern.matcher(textToTest); return !m.matches() && !GenericValidator.isEmail(textToTest) && !GenericValidator.isUrl(textToTest); }
Example 3
Source File: EmailValidator.java From pentaho-kettle with Apache License 2.0 | 5 votes |
public boolean validate( CheckResultSourceInterface source, String propertyName, List<CheckResultInterface> remarks, ValidatorContext context ) { String value = null; value = ValidatorUtils.getValueAsString( source, propertyName ); if ( !GenericValidator.isBlankOrNull( value ) && !GenericValidator.isEmail( value ) ) { JobEntryValidatorUtils.addFailureRemark( source, propertyName, VALIDATOR_NAME, remarks, JobEntryValidatorUtils.getLevelOnFail( context, VALIDATOR_NAME ) ); return false; } else { return true; } }
Example 4
Source File: MailValidation.java From hop with Apache License 2.0 | 4 votes |
public static boolean isRegExValid( String emailAdress ) { return GenericValidator.isEmail( emailAdress ); }
Example 5
Source File: MailValidation.java From hop with Apache License 2.0 | 4 votes |
public static boolean isRegExValid( String emailAdress ) { return GenericValidator.isEmail( emailAdress ); }
Example 6
Source File: DefaultSchemaValidator.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
private List<? extends ErrorReport> validateString( Class<?> klass, Object propertyObject, Property property ) { List<ErrorReport> errorReports = new ArrayList<>(); // TODO How should empty strings be handled? they are not valid color, password, url, etc of course. if ( !String.class.isInstance( propertyObject ) || StringUtils.isEmpty( propertyObject ) ) { return errorReports; } String value = (String) propertyObject; // check column max length if ( value.length() > property.getLength() ) { errorReports.add( new ErrorReport( klass, ErrorCode.E4001, property.getName(), property.getLength(), value.length() ) .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) ); return errorReports; } if ( value.length() < property.getMin() || value.length() > property.getMax() ) { errorReports.add( new ErrorReport( klass, ErrorCode.E4002, property.getName(), property.getMin(), property.getMax(), value.length() ) .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) ); } if ( PropertyType.EMAIL == property.getPropertyType() && !GenericValidator.isEmail( value ) ) { errorReports.add( new ErrorReport( klass, ErrorCode.E4003, property.getName(), value ) .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) ); } else if ( PropertyType.URL == property.getPropertyType() && !isUrl( value ) ) { errorReports.add( new ErrorReport( klass, ErrorCode.E4004, property.getName(), value ) .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) ); } else if ( !BCRYPT_PATTERN.matcher( value ).matches() && PropertyType.PASSWORD == property.getPropertyType() && !ValidationUtils.passwordIsValid( value ) ) { errorReports.add( new ErrorReport( klass, ErrorCode.E4005, property.getName(), value ) .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) ); } else if ( PropertyType.COLOR == property.getPropertyType() && !ValidationUtils.isValidHexColor( value ) ) { errorReports.add( new ErrorReport( klass, ErrorCode.E4006, property.getName(), value ) .setErrorKlass( property.getKlass() ).setErrorProperty( property.getName() ) ); } /* TODO add proper validation for both Points and Polygons, ValidationUtils only supports points at this time if ( PropertyType.GEOLOCATION == property.getPropertyType() && !ValidationUtils.coordinateIsValid( value ) ) { validationViolations.add( new ValidationViolation( "Value is not a valid coordinate pair [lon, lat]." ) ); } */ return errorReports; }
Example 7
Source File: MailValidation.java From pentaho-kettle with Apache License 2.0 | 4 votes |
public static boolean isRegExValid( String emailAdress ) { return GenericValidator.isEmail( emailAdress ); }
Example 8
Source File: ADMValidator.java From development with Apache License 2.0 | 3 votes |
/** * Checks if a field has and is a valid email address. * * @param value * The value validation is being performed on. A null value is * considered invalid. * @return true if the value is a valid email. */ public static boolean isEmail(String value) { if (GenericValidator.isEmail(value)) { return Pattern.matches("\\S.*@[a-zA-Z0-9\\-\\.]*", value); } return false; }
Example 9
Source File: Validators.java From sinavi-jfw with Apache License 2.0 | 2 votes |
/** * 指定された文字列がメールアドレスの形式かどうかを検査します。 * 検証アルゴリズムは、{@link GenericValidator#isEmail(String)}を利用しています。 * @param suspect 検査対象 * @return GenericValidator#isEmail(String)の結果 */ public static boolean isEmail(CharSequence suspect) { return GenericValidator.isEmail(suspect.toString()); }