How to use the vcard.vcard_errors.NOTE_INVALID_PARAMETER_VALUE 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 / tests / test_package.py View on Github external
'message': vcard_errors.NOTE_EMPTY_VCARD,
    'vcards': ('', None)}
VCARDS_INVALID_DATE = {
    'message': vcard_errors.NOTE_INVALID_DATE,
    'vcards': tuple()}
VCARDS_INVALID_LANGUAGE_VALUE = {
    'message': vcard_errors.NOTE_INVALID_LANGUAGE_VALUE,
    'vcards': ('invalid_language_value.vcf',)}
VCARDS_INVALID_LINE_SEPARATOR = {
    'message': vcard_errors.NOTE_INVALID_LINE_SEPARATOR,
    'vcards': ('line_ending_mac.vcf', 'line_ending_unix.vcf', 'line_ending_mixed.vcf',)}
VCARDS_INVALID_PARAM_NAME = {
    'message': vcard_errors.NOTE_INVALID_PARAMETER_NAME,
    'vcards': ('invalid_param_name.vcf',)}
VCARDS_INVALID_PARAM_VALUE = {
    'message': vcard_errors.NOTE_INVALID_PARAMETER_VALUE,
    'vcards': ('invalid_param_value.vcf',)}
VCARDS_INVALID_PROPERTY_NAME = {
    'message': vcard_errors.NOTE_INVALID_PROPERTY_NAME,
    'vcards': ('invalid_property_foo.vcf',)}
VCARDS_INVALID_SUB_VALUE = {
    'message': vcard_errors.NOTE_INVALID_SUB_VALUE,
    'vcards': tuple()}
VCARDS_INVALID_SUB_VALUE_COUNT = {
    'message': vcard_errors.NOTE_INVALID_SUB_VALUE_COUNT,
    'vcards': tuple()}
VCARDS_INVALID_TEXT_VALUE = {
    'message': vcard_errors.NOTE_INVALID_TEXT_VALUE,
    'vcards': tuple()}
VCARDS_INVALID_TIME = {
    'message': vcard_errors.NOTE_INVALID_TIME,
    'vcards': tuple()}
github l0b0 / vcard / vcard / vcard_validators.py View on Github external
    @param parameter: Single parameter, as returned by get_vcard_property_param

    Examples:
    >>> validate_text_parameter(['VALUE', {'ptext'}])
    """
    param_name = parameter[0].upper()
    param_values = parameter[1]

    if param_name == 'VALUE':
        if param_values != {'ptext'}:
            raise VCardValueError('{0}: {1}'.format(NOTE_INVALID_PARAMETER_VALUE, param_values), {})
        return
    elif param_name == 'LANGUAGE':
        if len(param_values) != 1:
            raise VCardValueError('{0}: {1}'.format(NOTE_INVALID_PARAMETER_VALUE, param_values), {})
        for param_value in param_values:
            validate_language_tag(param_value)
    else:
        validate_x_name(param_name)
        if len(param_values) != 1:
            raise VCardValueError('{0}: {1}'.format(NOTE_INVALID_PARAMETER_VALUE, param_values), {})
        validate_param_value(param_values[0])
github l0b0 / vcard / vcard / vcard_validators.py View on Github external
>>> validate_param_value('')
    >>> validate_param_value(SAFE_CHARACTERS)
    >>> validate_param_value(DOUBLE_QUOTE_CHARACTER + QUOTE_SAFE_CHARACTERS[0] + DOUBLE_QUOTE_CHARACTER)
    >>> validate_param_value(
    ... DOUBLE_QUOTE_CHARACTER + DOUBLE_QUOTE_CHARACTER) # doctest: +ELLIPSIS +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    VCardValueError: Invalid parameter value ...
    String: ""
    """
    try:
        validate_presentation_text(text)
    except VCardValueError:
        try:
            validate_quoted_string(text)
        except VCardValueError:
            raise VCardValueError(NOTE_INVALID_PARAMETER_VALUE, {'String': text})
github l0b0 / vcard / vcard / vcard_validators.py View on Github external
"""
    ptext, as described on page 28
    

    @param text: String

    Examples:
    >>> validate_presentation_text('')
    >>> validate_presentation_text(SAFE_CHARACTERS)
    >>> validate_presentation_text(u'\u000B') #doctest: +ELLIPSIS +IGNORE_EXCEPTION_DETAIL
    Traceback (most recent call last):
    VCardValueError: Invalid parameter value ...
    String: ...
    """
    if VALID_PRESENTATION_TEXT.match(text) is None:
        raise VCardValueError(NOTE_INVALID_PARAMETER_VALUE, {'String': text})
github l0b0 / vcard / vcard / vcard_validators.py View on Github external
param_name = parameter[0].upper()
    param_values = parameter[1]

    if param_name == 'VALUE':
        if param_values != {'ptext'}:
            raise VCardValueError('{0}: {1}'.format(NOTE_INVALID_PARAMETER_VALUE, param_values), {})
        return
    elif param_name == 'LANGUAGE':
        if len(param_values) != 1:
            raise VCardValueError('{0}: {1}'.format(NOTE_INVALID_PARAMETER_VALUE, param_values), {})
        for param_value in param_values:
            validate_language_tag(param_value)
    else:
        validate_x_name(param_name)
        if len(param_values) != 1:
            raise VCardValueError('{0}: {1}'.format(NOTE_INVALID_PARAMETER_VALUE, param_values), {})
        validate_param_value(param_values[0])