class CXValidator implements ValueValidator {

    @Override
    public void validate(String hl7CX) throws XDSMetaDataException {
        Identifiable identifiable = Hl7v2Based.parse(hl7CX, Identifiable.class);
        metaDataAssert(identifiable != null, CX_NEEDS_ID);

        CX cx = identifiable.getHapiObject();

        metaDataAssert(countMatches(hl7CX, "^") <= 3, CX_TOO_MANY_COMPONENTS);
        metaDataAssert(isEmpty(cx.getCx2_CheckDigit().getValue()), CX_TOO_MANY_COMPONENTS);
        metaDataAssert(isEmpty(cx.getCx3_CheckDigitScheme().getValue()), CX_TOO_MANY_COMPONENTS);

        metaDataAssert(isNotEmpty(cx.getCx1_IDNumber().getValue()), CX_NEEDS_ID);

        HD_VALIDATOR.validate(cx.getCx4_AssigningAuthority(), hl7CX);
    }

}