Exemplo n.º 1
0
    def validate_email(cls, v_field):  # pylint: disable=no-self-argument, no-self-use
        if not v_field:
            raise ValueError('must not empty')

        for email in v_field.split(','):
            networks.validate_email(email)

        return v_field
Exemplo n.º 2
0
    def validate_email(cls, v_field):
        if not v_field:
            raise ValueError('must not empty')

        for email in v_field.split(','):
            networks.validate_email(email)

        return v_field
Exemplo n.º 3
0
    def validate(  # type: ignore
        cls, value: str, field: "ModelField", config: "BaseConfig"
    ) -> Union["AnyUrl", str]:
        """ """
        if value.startswith("mailto:"):
            schema = value[0:7]
            email = value[7:]
            realname = parseaddr(email)[0]
            name, email = validate_email(email)
            if realname:
                email = formataddr((name, email))
            return schema + email
        elif value.startswith("mllp:") or value.startswith("llp:"):
            # xxx: find validation
            return value
        elif value in FHIR_PRIMITIVES:
            # Extensions may contain a valueUrl for a primitive FHIR type
            return value

        return AnyUrl.validate(value, field, config)
Exemplo n.º 4
0
def test_email_validator_not_installed():
    with pytest.raises(ImportError):
        validate_email('*****@*****.**')
Exemplo n.º 5
0
def test_address_invalid(value):
    with pytest.raises(ValueError):
        validate_email(value)
Exemplo n.º 6
0
def test_address_valid(value, name, email):
    assert validate_email(value) == (name, email)