Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
CaosDB Crawler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
CaosDB Crawler
Commits
bd388c86
Commit
bd388c86
authored
5 months ago
by
Alexander Schlemmer
Browse files
Options
Downloads
Patches
Plain Diff
DOC(validator): doc updated to describe new behavior
parent
a140962d
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!217
TST: Make NamedTemporaryFiles Windows-compatible
,
!201
Validator that checks created records using a json schema
Pipeline
#58355
passed
5 months ago
Stage: info
Stage: setup
Stage: cert
Stage: style
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/caoscrawler/validator.py
+12
-9
12 additions, 9 deletions
src/caoscrawler/validator.py
with
12 additions
and
9 deletions
src/caoscrawler/validator.py
+
12
−
9
View file @
bd388c86
...
...
@@ -123,12 +123,14 @@ def convert_record(record: db.Record):
return
_apply_schema_patches
(
pobj
)
def
validate
(
records
:
list
[
db
.
Record
],
schemas
:
dict
[
str
,
dict
])
->
list
[
tuple
[
bool
,
list
]
]:
def
validate
(
records
:
list
[
db
.
Record
],
schemas
:
dict
[
str
,
dict
])
->
list
[
tuple
]:
"""
Validate a list of records against a list of possible JSON schemas.
It is tried to validate each schema from the list of schemas. If none of them validates
without error, it is assumed that it does not match at all.
Validate a list of records against a dictionary of schemas.
The keys of the dictionary are record types and the corresponding values are json schemata
associated with that record type. The current implementation assumes that each record that is
checked has exactly one parent and raises an error if that is not the case.
The schema belonging to a record is identified using the name of the first (and only) parent
of the record.
Arguments:
----------
...
...
@@ -136,15 +138,16 @@ def validate(records: list[db.Record], schemas: dict[str, dict]) -> list[tuple[b
records: list[db.Record]
List of records that will be validated.
schemas:
list[
dict]
A
list
of JSON schemas generated using `load_json_schema_from_datamodel_yaml`.
schemas:
dict[str,
dict]
A
dictionary
of JSON schemas generated using `load_json_schema_from_datamodel_yaml`.
Returns:
--------
A list of tuples, one element for each record:
- Index 0: A boolean that determines whether at least one schema matched for this record.
- Index 1: A list of schemas matching the record at this position of the list `records`.
- Index 0: A boolean that determines whether the schema belonging to the record type of the
record matched.
- Index 1: A validation error if the schema did not match or None otherwise.
"""
retval
=
[]
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment