Java Code Examples for org.apache.commons.validator.GenericTypeValidator#formatInt()

The following examples show how to use org.apache.commons.validator.GenericTypeValidator#formatInt() . 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: IntegerValidator.java    From hop with Apache License 2.0 6 votes vote down vote up
public boolean validate( ICheckResultSource source, String propertyName,
                         List<ICheckResult> remarks, ValidatorContext context ) {

  Object result = null;
  String value = null;

  value = ValidatorUtils.getValueAsString( source, propertyName );

  if ( GenericValidator.isBlankOrNull( value ) ) {
    return true;
  }

  result = GenericTypeValidator.formatInt( value );

  if ( result == null ) {
    ActionValidatorUtils.addFailureRemark( source, propertyName, VALIDATOR_NAME, remarks,
      ActionValidatorUtils.getLevelOnFail( context, VALIDATOR_NAME ) );
    return false;
  }
  return true;

}
 
Example 2
Source File: IntegerValidator.java    From pentaho-kettle with Apache License 2.0 6 votes vote down vote up
public boolean validate( CheckResultSourceInterface source, String propertyName,
  List<CheckResultInterface> remarks, ValidatorContext context ) {

  Object result = null;
  String value = null;

  value = ValidatorUtils.getValueAsString( source, propertyName );

  if ( GenericValidator.isBlankOrNull( value ) ) {
    return true;
  }

  result = GenericTypeValidator.formatInt( value );

  if ( result == null ) {
    JobEntryValidatorUtils.addFailureRemark( source, propertyName, VALIDATOR_NAME, remarks,
        JobEntryValidatorUtils.getLevelOnFail( context, VALIDATOR_NAME ) );
    return false;
  }
  return true;

}