Validator
Validator class for document-level validation on Stores. Attach an instance of a Validator subclass to a Store .schema variable to enable validation on that Store.
Validator
¶
Bases: MSONable
A generic class to perform document-level validation on Stores. Attach a Validator to a Store during initialization, any all documents added to the Store will call .validate_doc() before being added.
Source code in src/maggma/core/validator.py
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
|
is_valid(doc)
abstractmethod
¶
Determines if the document is valid.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc |
dict
|
document to check |
required |
Source code in src/maggma/core/validator.py
19 20 21 22 23 24 25 26 |
|
validation_errors(doc)
abstractmethod
¶
If document is not valid, provides a list of strings to display for why validation has failed.
Returns empty list if the document is valid
Parameters:
Name | Type | Description | Default |
---|---|---|---|
doc |
dict
|
document to check |
required |
Source code in src/maggma/core/validator.py
28 29 30 31 32 33 34 35 36 37 38 |
|