/** * Checks this vCard for data consistency problems or deviations from the * spec. These problems will not prevent the vCard from being written to a * data stream, but may prevent it from being parsed correctly by the * consuming application. These problems can largely be avoided by reading * the Javadocs of the property classes, or by being familiar with the vCard * standard. * @param version the version to check the vCard against (use * {@link VCardVersion#V4_0} for xCard and jCard) * @return the validation warnings */ public ValidationWarnings validate(VCardVersion version) { ValidationWarnings warnings = new ValidationWarnings(); //validate overall vCard object if (getStructuredName() == null && (version == VCardVersion.V2_1 || version == VCardVersion.V3_0)) { warnings.add(null, new ValidationWarning(0)); } if (getFormattedName() == null && (version == VCardVersion.V3_0 || version == VCardVersion.V4_0)) { warnings.add(null, new ValidationWarning(1)); } //validate properties for (VCardProperty property : this) { List<ValidationWarning> propWarnings = property.validate(version, this); if (!propWarnings.isEmpty()) { warnings.add(property, propWarnings); } } return warnings; }