checkValidity method
Classes can implement this to check the validity.
If the component missed required information, throw a FormatException with details.
Implementation
@override
void checkValidity() {
super.checkValidity();
checkMandatoryProperty(TextProperty.propertyNameTimezoneId);
if (children.isEmpty) {
throw const FormatException(
'A valid VTIMEZONE requires at least one STANDARD or one DAYLIGHT sub-component');
}
var numberOfStandardChildren = 0, numberOfDaylightChildren = 0;
for (final phase in children) {
if (phase.componentType == VComponentType.timezonePhaseStandard) {
numberOfStandardChildren++;
} else if (phase.componentType == VComponentType.timezonePhaseDaylight) {
numberOfDaylightChildren++;
}
}
if (numberOfStandardChildren == 0 && numberOfDaylightChildren == 0) {
throw const FormatException(
'A valid VTIMEZONE requires at least one STANDARD or one DAYLIGHT sub-component');
}
}