How to use the vcard.vcard_validators.validate_vcard_property function in vcard

To help you get started, we’ve selected a few vcard examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github l0b0 / vcard / vcard / vcard_validator.py View on Github external
property_name_and_params = vcard_utils.split_unescaped(property_string, ';')

    property_ = VcardProperty(property_name_and_params.pop(0))

    # String validation
    if not property_.name.upper() in ALL_PROPERTIES and not re.match(
            '^X-[{0}]+$'.format(re.escape(ID_CHARACTERS)), property_.name, re.IGNORECASE):
        raise VCardNameError('{0}: {1}'.format(NOTE_INVALID_PROPERTY_NAME, property_.name), {})

    try:
        if len(property_name_and_params) != 0:
            property_.parameters = get_vcard_property_params(';'.join(property_name_and_params))
        property_.values = get_vcard_property_values(values_string)

        # Validate
        vcard_validators.validate_vcard_property(property_)
    except VCardError as error:
        # Add parameter name to error
        error.context['Property line'] = property_line
        err_type = type(error)
        raise err_type(error.message, error.context)

    return property_