Skip to content

Commit

Permalink
Added new validators to zon by default
Browse files Browse the repository at this point in the history
  • Loading branch information
Naapperas committed Nov 24, 2023
1 parent b47903d commit ed3288b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
18 changes: 18 additions & 0 deletions zon/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
from zon.str import ZonString
from zon.union import ZonUnion
from zon.record import ZonRecord
from zon.any import ZonAny
from zon.none import ZonNone


def string() -> "ZonString":
Expand Down Expand Up @@ -92,3 +94,19 @@ def record(properties: dict[str, "Zon"]) -> "ZonRecord":
an object with the specified properties.
"""
return ZonRecord(properties)

def none() -> "ZonNone":
"""Creates a new Zon that validates that the data is None.
Returns:
ZonNone: a new validator that validates that the data is None.
"""
return ZonNone()

def anything() -> "ZonAny":
"""Creates a new Zon that validates anything.
Returns:
ZonAny: a new validator that validates anything.
"""
return ZonAny()
2 changes: 1 addition & 1 deletion zon/any.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from .base import Zon


class ZonNone(Zon):
class ZonAny(Zon):
"""A Zon that validates that the data is any data type."""

def _setup(self) -> None:
Expand Down

0 comments on commit ed3288b

Please sign in to comment.