This repository has been archived by the owner on Dec 13, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dded validation_rules property to Node class for automatic input
validation. #5 added tests for validation rules. updated version: 0.2.1
- Loading branch information
Showing
4 changed files
with
105 additions
and
42 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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
from .grest import GRest | ||
|
||
__version__ = '0.2' | ||
__version__ = '0.2.1' |
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
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
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,32 @@ | ||
from neomodel import * | ||
from webargs import fields | ||
import grest | ||
|
||
|
||
class model(StructuredNode, grest.utils.Node): | ||
GREEK = ( | ||
("A", "Alpha"), | ||
("B", "Beta"), | ||
("G", "Gamma") | ||
) | ||
|
||
uuid = UniqueIdProperty() | ||
string = StringProperty(required=True) | ||
choices = StringProperty(choices=GREEK) | ||
integer = IntegerProperty() | ||
json = JSONProperty() | ||
array_of_string = ArrayProperty(StringProperty()) | ||
raw_data = ArrayProperty() | ||
date = DateProperty() | ||
datetime = DateTimeProperty() | ||
boolean = BooleanProperty() | ||
email = EmailProperty() | ||
|
||
|
||
def test_validation_rules_property(): | ||
instance = model() | ||
|
||
for rule in instance.__validation_rules__.items(): | ||
assert isinstance(rule[1], fields.Field) | ||
if isinstance(rule[1], fields.List): | ||
assert isinstance(rule[1].container, fields.Field) |