-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |