mangstadt / biweekly

biweekly is an iCalendar library written in Java.
BSD 2-Clause "Simplified" License
323 stars 44 forks source link

Feature Request: Option for strict parsing #123

Open linusclindgren opened 1 year ago

linusclindgren commented 1 year ago

I'd like the option to parse iCals strictly. If this is not the consensus of developers in the project, perhaps the warnings in the ChainingParser could be made public. This way at least it will be possible to see any warnings and throw an exception with the warnings.

abstract class ChainingParser<T extends ChainingParser<?>> {

...

public List<List<ParseWarning>> warnings;
mangstadt commented 1 year ago

If you pass an empty list into the "warnings" method of the chaining parser, it will add the parse warnings to the list.

List<List<ParseWarning>> warnings = new ArrayList<List<ParseWarning>>();

ICalendar ical = Biweekly.parse(new File("...")).warnings(warnings).first();

List<ParseWarning> warningsFromFirstICalThatWasParsed = warnings.get(0);
for (ParseWarning warning : warningsFromFirstICalThatWasParsed){
  //...
}