Package com.ebay.sdk.attributes.model

Examples of com.ebay.sdk.attributes.model.ValidationResult


    return result;
  }

  public static ValidationResult MinDoubleValidationRule(Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    if (isValidId(id.intValue()) && cnt.intValue() > 0) {
      result.setSuccess(true);
    }
    else if (isValid(target)) {
        try {
          result.setSuccess(Double.parseDouble(target) > Double.parseDouble(rule.min));
        }
        catch(Exception e) {
        }
    }
    result.setErrorMessage("Please enter a value greater than [" + rule.min + "].");
    return result;
  }
View Full Code Here


    return result;
  }

  public static ValidationResult MinIntValidationRule(Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    if (isValidId(id.intValue()) && cnt.intValue() > 0) {
      result.setSuccess(true);
    }
    else if (isValid(target)) {
        try {
          result.setSuccess(Double.parseDouble(target) > Integer.parseInt(rule.min));
        }
        catch(Exception e) {
        }
    }
    result.setErrorMessage("Please enter an value greater than [" + rule.min + "].");
    return result;
  }
View Full Code Here

    return result;
  }

  public static ValidationResult MultiSelectMinNumberValuesRule(Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    result.setSuccess(cnt.intValue() > Integer.parseInt(rule.min));
    result.setErrorMessage("Please make no fewer than [" + rule.min + "] selections.");
    return result;
  }
View Full Code Here

    return result;
  }

  public static ValidationResult MultiSelectMaxNumberValuesRule(Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    result.setSuccess(cnt.intValue() < Integer.parseInt(rule.max));
    result.setErrorMessage("Please make no more than [" + rule.max + "] selections.");
    return result;
  }
View Full Code Here

    return result;
  }

  public static ValidationResult MultiSelectMinMaxNumberValuesRule(Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    int val = cnt.intValue();
    result.setSuccess(Integer.parseInt(rule.min) < val && val < Integer.parseInt(rule.max));
    result.setErrorMessage("Please make between [" + rule.min + "] and [" + rule.max + "] selections.");
    return result;
  }
View Full Code Here

    return result;
  }

  public static ValidationResult NumberSeparatorNotAllowedRule(Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    if (isValidId(id.intValue()) && cnt.intValue() > 0) {
      result.setSuccess(true);
    }
    else if (isValid(target)) {
      target = target.trim();
      if (target.startsWith("-"))
      {
        target = target.substring(1, target.length() - 1);
      }
      target = target.trim();
      char [] ca = target.toCharArray();
      int len = ca.length;
      int i = 0;
      boolean success = true;
      while (success && i < len)
      {
        success = Character.isDigit(ca[i]);
        i ++;
      }
      result.setSuccess(success);
    }
    result.setErrorMessage("Please enter only numeric digits with no symbols.");
    return result;
  }
View Full Code Here

    return result;
  }

  public static ValidationResult PrecisionRule(Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    if (isValidId(id.intValue()) && cnt.intValue() > 0) {
      result.setSuccess(true);
    }
    else if( target.length() == 0 || isNumber(target) != 0 )
      result.setSuccess(true);
    result.setErrorMessage("PrecisionRule violation (" + rule.precision + ").");
    return result;
  }
View Full Code Here

  }

  public static ValidationResult RegularExpressionValidationRule(Integer id, Integer cnt, String target, ValidationRule rule)
    throws MalformedPatternException
  {
    ValidationResult result = new ValidationResult();
    if (isValidId(id.intValue()) && cnt.intValue() > 0) {
      result.setSuccess(true);
    }
    else if (isValid(target)) {
      Perl5Compiler perl = getPerlCompiler();
      Perl5Matcher matcher = getRegMatcher();
      Pattern pat = perl.compile(rule.other);
      result.setSuccess(matcher.matches(target, pat));
    }
    result.setErrorMessage("Please enter this value in the format requested: " + rule.other);
    return result;
  }
View Full Code Here

    return result;
  }

  public static ValidationResult RequiredRule(Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    result.setSuccess(cnt.intValue() > 0);
    result.setErrorMessage("RequiredRule violation.");
    return result;
  }
View Full Code Here

  }

  //TODO
  public static ValidationResult SimpleRuleSetRule (Integer id, Integer cnt, String target, ValidationRule rule)
  {
    ValidationResult result = new ValidationResult();
    if (isValidId(id.intValue()) && cnt.intValue() > 0) {
      result.setSuccess(true);
    }
    else {
      // This rule is not supported
      result.setSuccess(true);
    }
    result.setErrorMessage("SimpleRuleSetRule violation.");
    return result;
  }
View Full Code Here

TOP

Related Classes of com.ebay.sdk.attributes.model.ValidationResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.