Example #1
0
  @Override
  protected void validate(
      List<ICalComponent> components, ICalVersion version, List<Warning> warnings) {
    if (dates.isEmpty() && periods.isEmpty()) {
      // no value
      warnings.add(Warning.validate(26));
    }

    if (!dates.isEmpty() && !periods.isEmpty()) {
      // can't mix dates and periods
      warnings.add(Warning.validate(49));
    }

    if (version == ICalVersion.V1_0 && !periods.isEmpty()) {
      // 1.0 doesn't support periods
      warnings.add(Warning.validate(51));
    }

    if (!dates.isEmpty()) {
      // can't mix date and date-time values
      boolean hasTime = dates.get(0).hasTime();
      for (ICalDate date : dates.subList(1, dates.size())) {
        if (date.hasTime() != hasTime) {
          warnings.add(Warning.validate(50));
          break;
        }
      }
    }
  }
Example #2
0
 @Override
 protected void validate(
     List<ICalComponent> components, ICalVersion version, List<Warning> warnings) {
   Pattern validCharacters = Pattern.compile("(?i)[-a-z0-9]+");
   if (!validCharacters.matcher(name).matches()) {
     warnings.add(Warning.validate(52, name));
   }
 }