Skip to content

Commit

Permalink
Added more types
Browse files Browse the repository at this point in the history
  • Loading branch information
Naapperas committed Nov 24, 2023
1 parent 839f198 commit b47903d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
13 changes: 13 additions & 0 deletions zon/any.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""Class and methods related to the ZonAny validator."""

from .base import Zon


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

def _setup(self) -> None:
self.validators["_default_"] = self._default_validate

def _default_validate(self, _data):
return True
17 changes: 17 additions & 0 deletions zon/none.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""Class and methods related to the ZonNone validator."""

from .base import Zon
from .error import ValidationError


class ZonNone(Zon):
"""A Zon that validates that the data is None."""

def _setup(self) -> None:
self.validators["_default_"] = self._default_validate

def _default_validate(self, data):
if data is not None:
self._add_error(ValidationError(f"Expected None, got {type(data)}"))
return False
return True

0 comments on commit b47903d

Please sign in to comment.