Package propel.core.validation

Examples of propel.core.validation.ValidationException


    if (!getLocalPartOnlyAllowed())
    {
      // then it must contain the at sign
      int atCount = StringUtils.count(email, CONSTANT.AT_SIGN_CHAR);
      if (atCount < 1)
        throw new ValidationException(String.format(EMAIL_DOES_NOT_CONTAIN_AT_SIGN, getName()));
      else if (atCount > 1)
        throw new ValidationException(String.format(EMAIL_CONTAINS_MANY_AT_SIGNS, getName()));
    }
  }
View Full Code Here


  protected void checkBounds(Duration value)
      throws ValidationException
  {
    // check conditions
    if (value.compareTo(getMaxValue()) > 0)
      throw new ValidationException(String.format(BoundedValueTypePropertyMetadata.SHOULD_NOT_BE_GREATER_THAN, getName())
          + getMaxValue().getStandardSeconds() + " secs.");

    if (value.compareTo(getMinValue()) < 0)
      throw new ValidationException(String.format(BoundedValueTypePropertyMetadata.SHOULD_NOT_BE_LESS_THAN, getName())
          + getMinValue().getStandardSeconds() + " secs.");
  }
View Full Code Here

          System.arraycopy(lastGroups, 0, groups, MAX_NUM_HEX_GROUPS - lastGroups.length, lastGroups.length);
        }
      } else if (numOfDoubleColons == 0)
        groups = StringUtils.split(value, CONSTANT.COLON_CHAR);
      else
        throw new ValidationException(String.format(IP_INVALID_NUMBER_OF_DOUBLE_COLONS, getName()) + numOfDoubleColons);

      // must have 8 groups
      if (groups.length != MAX_NUM_HEX_GROUPS)
        throw new ValidationException(String.format(IP_INVALID_NUMBER_OF_GROUPS, getName()) + groups.length);
    } else
      throw new ValidationException(String.format(IP_INVALID_NUMBER_OF_COLONS, getName()) + numOfColons);
  }
View Full Code Here

  protected void checkBounds(Period value)
      throws ValidationException
  {
    // check conditions   
    if (value.toStandardSeconds().getSeconds() > getMaxValue().toStandardSeconds().getSeconds())
      throw new ValidationException(String.format(BoundedValueTypePropertyMetadata.SHOULD_NOT_BE_GREATER_THAN, getName()) + getMaxValue());

    if (value.toStandardSeconds().getSeconds() < getMinValue().toStandardSeconds().getSeconds())
      throw new ValidationException(String.format(BoundedValueTypePropertyMetadata.SHOULD_NOT_BE_LESS_THAN, getName()) + getMinValue());
  }
View Full Code Here

      throws ValidationException
  {
    if (getNoUnicodeChars())
      for (char ch : value)
        if (ch >= 128)
          throw new ValidationException(String.format(UNICODE_CHARACTERS_NOT_ALLOWED, getName()) + "'" + ch + "'");
  }
View Full Code Here

  {
    if (value.length > 0)
    {
      char first = value[0];
      if (Linq.contains(getDisallowedStartChars(), first))
        throw new ValidationException(String.format(CANNOT_START_WITH, getName()) + "'" + first + "'");

      char last = value[value.length - 1];
      if (Linq.contains(getDisallowedEndChars(), last))
        throw new ValidationException(String.format(CANNOT_END_WITH, getName()) + "'" + last + "'");
    }
  }
View Full Code Here

  protected void checkIpv4Address(char[] value)
      throws ValidationException
  {
    if (StringUtils.count(value, CONSTANT.DOT_CHAR) != 3)
      throw new ValidationException(String.format(IP_MISSING_DOTS_MALFORMED, getName()));

    List<char[]> octets = StringUtils.split(value, CONSTANT.DOT_CHAR);
    if (octets.size() != 4)
      throw new ValidationException(String.format(IP_MISSING_OCTET_MALFORMED, getName()));

    for (char[] octet : octets)
    {
      String octetString = StringUtils.concat(octet);

      // parse
      try
      {
        StringUtils.parseUInt8(octetString);
      }
      catch(Throwable e)
      {
        throw new ValidationException(String.format(IP_OCTET_PROBLEM, getName()) + octetString);
      }
    }
  }
View Full Code Here

  protected void checkNotNullChar(char value)
      throws ValidationException
  {
    if (getNotNullChar())
      if (value == CONSTANT.NULL_CHAR)
        throw new ValidationException(String.format(SHOULD_NOT_BE_NULL_CHAR, getName()));
  }
View Full Code Here

  protected void checkAllCharsAllowed(char[] value)
      throws ValidationException
  {
    for (char ch : value)
      if (!Linq.contains(getAllowedChars(), ch))
        throw new ValidationException(String.format(CANNOT_CONTAIN, getName()) + "'" + ch + "'");
  }
View Full Code Here

      {
        getIpv6PropMeta().validate(value);
      }
      catch(ValidationException e2)
      {
        throw new ValidationException(String.format(NOT_AN_IP_ADDRESS, getName()));
      }
    }
  }
View Full Code Here

TOP

Related Classes of propel.core.validation.ValidationException

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.