class XCNValidator implements ValueValidator {

    @Override
    public void validate(String hl7xcn) throws XDSMetaDataException {
        Person person = Hl7v2Based.parse(hl7xcn, Person.class);
        metaDataAssert(person != null, PERSON_MISSING_NAME_AND_ID, hl7xcn);

        XCN xcn = person.getHapiObject();
        metaDataAssert(
                isNotEmpty(xcn.getXcn1_IDNumber().getValue()) ||
                isNotEmpty(xcn.getXcn2_FamilyName().getFn1_Surname().getValue()),
                PERSON_MISSING_NAME_AND_ID, hl7xcn);

//        Spec actually allows the assigning authority to be missing:
//          "If component 1 (ID Number) is specified, component 9 (Assigning Authority) shall be present if available"
//        metaDataAssert(idNumber == null || hl7hd != null, PERSON_HD_MISSING, hl7xcn);


        HD hd = xcn.getXcn9_AssigningAuthority();
        if (! HD_VALIDATOR.isEmpty(hd)) {
            HD_VALIDATOR.validate(hd, hl7xcn);
        }
    }

}