Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed typos + made spelling more consistent #431

Merged
merged 2 commits into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

**What does this mean?** I do not have time to fix issues myself. The only way fixes or new features will be added is by people submitting PRs.

**Current status.** Voluptuous is largely feature stable. There hasn't been a need to add new features in a while, but there are some bugs that should be fixed.
**Current status:** Voluptuous is largely feature stable. There hasn't been a need to add new features in a while, but there are some bugs that should be fixed.

**Why?** I no longer use Voluptuous personally (in fact I no longer regularly write Python code). Rather than leave the project in a limbo of people filing issues and wondering why they're not being worked on, I believe this notice will more clearly set expectations.

Expand Down Expand Up @@ -41,6 +41,28 @@ The documentation is provided [here](http://alecthomas.github.io/voluptuous/).

See [CHANGELOG.md](https://github.com/alecthomas/voluptuous/blob/master/CHANGELOG.md).

## Why use Voluptuous over another validation library?

**Validators are simple callables:**
No need to subclass anything, just use a function.

**Errors are simple exceptions:**
A validator can just `raise Invalid(msg)` and expect the user to get
useful messages.

**Schemas are basic Python data structures:**
Should your data be a dictionary of integer keys to strings?
`{int: str}` does what you expect. List of integers, floats or
strings? `[int, float, str]`.

**Designed from the ground up for validating more than just forms:**
Nested data structures are treated in the same way as any other
type. Need a list of dictionaries? `[{}]`

**Consistency:**
Types in the schema are checked as types. Values are compared as
values. Callables are called to validate. Simple.

## Show me an example

Twitter's [user search API](https://dev.twitter.com/rest/reference/get/users/search) accepts
Expand Down Expand Up @@ -688,35 +710,13 @@ cross-field validator will not run:
s({'password':'123', 'password_again': 1337})
```

## Running tests.
## Running tests

Voluptuous is using nosetests:

$ nosetests


## Why use Voluptuous over another validation library?

**Validators are simple callables**
: No need to subclass anything, just use a function.

**Errors are simple exceptions.**
: A validator can just `raise Invalid(msg)` and expect the user to get
useful messages.

**Schemas are basic Python data structures.**
: Should your data be a dictionary of integer keys to strings?
`{int: str}` does what you expect. List of integers, floats or
strings? `[int, float, str]`.

**Designed from the ground up for validating more than just forms.**
: Nested data structures are treated in the same way as any other
type. Need a list of dictionaries? `[{}]`

**Consistency.**
: Types in the schema are checked as types. Values are compared as
values. Callables are called to validate. Simple.

## Other libraries and inspirations

Voluptuous is heavily inspired by
Expand Down
4 changes: 2 additions & 2 deletions voluptuous/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,11 @@ class BooleanInvalid(Invalid):


class UrlInvalid(Invalid):
"""The value is not a url."""
"""The value is not a URL."""


class EmailInvalid(Invalid):
"""The value is not a email."""
"""The value is not an email address."""


class FileInvalid(Invalid):
Expand Down
50 changes: 25 additions & 25 deletions voluptuous/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,79 +197,79 @@ class C2:


def test_email_validation():
""" test with valid email """
""" test with valid email address """
schema = Schema({"email": Email()})
out_ = schema({"email": "example@example.com"})

assert 'example@example.com"', out_.get("url")


def test_email_validation_with_none():
""" test with invalid None Email"""
""" test with invalid None email address """
schema = Schema({"email": Email()})
try:
schema({"email": None})
except MultipleInvalid as e:
assert_equal(str(e),
"expected an Email for dictionary value @ data['email']")
"expected an email address for dictionary value @ data['email']")
else:
assert False, "Did not raise Invalid for None url"
assert False, "Did not raise Invalid for None URL"


def test_email_validation_with_empty_string():
""" test with empty string Email"""
""" test with empty string email address"""
schema = Schema({"email": Email()})
try:
schema({"email": ''})
except MultipleInvalid as e:
assert_equal(str(e),
"expected an Email for dictionary value @ data['email']")
"expected an email address for dictionary value @ data['email']")
else:
assert False, "Did not raise Invalid for empty string url"
assert False, "Did not raise Invalid for empty string URL"


def test_email_validation_without_host():
""" test with empty host name in email """
""" test with empty host name in email address """
schema = Schema({"email": Email()})
try:
schema({"email": 'a@.com'})
except MultipleInvalid as e:
assert_equal(str(e),
"expected an Email for dictionary value @ data['email']")
"expected an email address for dictionary value @ data['email']")
else:
assert False, "Did not raise Invalid for empty string url"
assert False, "Did not raise Invalid for empty string URL"


def test_fqdn_url_validation():
""" test with valid fully qualified domain name url """
""" test with valid fully qualified domain name URL """
schema = Schema({"url": FqdnUrl()})
out_ = schema({"url": "http://example.com/"})

assert 'http://example.com/', out_.get("url")


def test_fqdn_url_without_domain_name():
""" test with invalid fully qualified domain name url """
""" test with invalid fully qualified domain name URL """
schema = Schema({"url": FqdnUrl()})
try:
schema({"url": "http://localhost/"})
except MultipleInvalid as e:
assert_equal(str(e),
"expected a Fully qualified domain name URL for dictionary value @ data['url']")
"expected a fully qualified domain name URL for dictionary value @ data['url']")
else:
assert False, "Did not raise Invalid for None url"
assert False, "Did not raise Invalid for None URL"


def test_fqdnurl_validation_with_none():
""" test with invalid None FQDN url"""
""" test with invalid None FQDN URL """
schema = Schema({"url": FqdnUrl()})
try:
schema({"url": None})
except MultipleInvalid as e:
assert_equal(str(e),
"expected a Fully qualified domain name URL for dictionary value @ data['url']")
"expected a fully qualified domain name URL for dictionary value @ data['url']")
else:
assert False, "Did not raise Invalid for None url"
assert False, "Did not raise Invalid for None URL"


def test_fqdnurl_validation_with_empty_string():
Expand All @@ -279,9 +279,9 @@ def test_fqdnurl_validation_with_empty_string():
schema({"url": ''})
except MultipleInvalid as e:
assert_equal(str(e),
"expected a Fully qualified domain name URL for dictionary value @ data['url']")
"expected a fully qualified domain name URL for dictionary value @ data['url']")
else:
assert False, "Did not raise Invalid for empty string url"
assert False, "Did not raise Invalid for empty string URL"


def test_fqdnurl_validation_without_host():
Expand All @@ -291,9 +291,9 @@ def test_fqdnurl_validation_without_host():
schema({"url": 'http://'})
except MultipleInvalid as e:
assert_equal(str(e),
"expected a Fully qualified domain name URL for dictionary value @ data['url']")
"expected a fully qualified domain name URL for dictionary value @ data['url']")
else:
assert False, "Did not raise Invalid for empty string url"
assert False, "Did not raise Invalid for empty string URL"


def test_url_validation():
Expand All @@ -305,15 +305,15 @@ def test_url_validation():


def test_url_validation_with_none():
""" test with invalid None url"""
""" test with invalid None URL"""
schema = Schema({"url": Url()})
try:
schema({"url": None})
except MultipleInvalid as e:
assert_equal(str(e),
"expected a URL for dictionary value @ data['url']")
else:
assert False, "Did not raise Invalid for None url"
assert False, "Did not raise Invalid for None URL"


def test_url_validation_with_empty_string():
Expand All @@ -325,7 +325,7 @@ def test_url_validation_with_empty_string():
assert_equal(str(e),
"expected a URL for dictionary value @ data['url']")
else:
assert False, "Did not raise Invalid for empty string url"
assert False, "Did not raise Invalid for empty string URL"


def test_url_validation_without_host():
Expand All @@ -337,7 +337,7 @@ def test_url_validation_without_host():
assert_equal(str(e),
"expected a URL for dictionary value @ data['url']")
else:
assert False, "Did not raise Invalid for empty string url"
assert False, "Did not raise Invalid for empty string URL"


def test_copy_dict_undefined():
Expand Down
Loading