Email and URL validators

StrictYAML can validate emails (using a simplified regex) and URLs.

from strictyaml import Email, Url, Map, load
from ensure import Ensure

schema = Map({"a": Email(), "b": Url()})

Parsed:

a: billg@microsoft.com
b: http://www.twitter.com/@realDonaldTrump
Ensure(load(yaml_snippet, schema)).equals({"a": "billg@microsoft.com", "b": "http://www.twitter.com/@realDonaldTrump"})

Exception:

a: notanemail
b: notaurl
load(yaml_snippet, schema)
strictyaml.exceptions.YAMLValidationError:
when expecting an email address
found non-matching string
  in "<unicode string>", line 1, column 1:
    a: notanemail
     ^ (line: 1)

Executable specification

Documentation automatically generated from email-url.story storytests.