Final Implementation of Validation Options
This commit is contained in:
@@ -2,6 +2,10 @@ from jambo.parser._type_parser import GenericTypeParser
|
||||
|
||||
from typing import TypeVar
|
||||
|
||||
from jambo.utils.properties_builder.mappings_properties_builder import (
|
||||
mappings_properties_builder,
|
||||
)
|
||||
|
||||
V = TypeVar("V")
|
||||
|
||||
|
||||
@@ -16,4 +20,10 @@ class ArrayTypeParser(GenericTypeParser):
|
||||
properties["items"]["type"]
|
||||
).from_properties(name, properties["items"])
|
||||
|
||||
return list[_item_type], {}
|
||||
_mappings = {
|
||||
"maxItems": "max_items",
|
||||
"minItems": "min_items",
|
||||
"uniqueItems": "unique_items",
|
||||
}
|
||||
|
||||
return list[_item_type], mappings_properties_builder(properties, _mappings)
|
||||
|
||||
@@ -8,4 +8,4 @@ class BooleanTypeParser(GenericTypeParser):
|
||||
|
||||
@staticmethod
|
||||
def from_properties(name, properties):
|
||||
return bool, {}
|
||||
return bool, {} # The second argument is not used in this case
|
||||
|
||||
@@ -10,5 +10,7 @@ class ObjectTypeParser(GenericTypeParser):
|
||||
def from_properties(name, properties):
|
||||
from jambo.schema_converter import SchemaConverter
|
||||
|
||||
_type = SchemaConverter.build_object(name, properties)
|
||||
return _type, {}
|
||||
return (
|
||||
SchemaConverter.build_object(name, properties),
|
||||
{}, # The second argument is not used in this case
|
||||
)
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
from jambo.parser._type_parser import GenericTypeParser
|
||||
from jambo.utils.properties_builder.mappings_properties_builder import (
|
||||
mappings_properties_builder,
|
||||
)
|
||||
|
||||
|
||||
class StringTypeParser(GenericTypeParser):
|
||||
@@ -14,8 +17,4 @@ class StringTypeParser(GenericTypeParser):
|
||||
"pattern": "pattern",
|
||||
}
|
||||
|
||||
return str, {
|
||||
_mappings[key]: value
|
||||
for key, value in properties.items()
|
||||
if key in _mappings
|
||||
}
|
||||
return str, mappings_properties_builder(properties, _mappings)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
def mappings_properties_builder(properties, mappings):
|
||||
return {
|
||||
mappings[key]: value for key, value in properties.items() if key in mappings
|
||||
}
|
||||
@@ -1,3 +1,8 @@
|
||||
from jambo.utils.properties_builder.mappings_properties_builder import (
|
||||
mappings_properties_builder,
|
||||
)
|
||||
|
||||
|
||||
def numeric_properties_builder(properties):
|
||||
_mappings = {
|
||||
"minimum": "ge",
|
||||
@@ -7,8 +12,4 @@ def numeric_properties_builder(properties):
|
||||
"multipleOf": "multiple_of",
|
||||
}
|
||||
|
||||
return {
|
||||
_mappings[key]: value
|
||||
for key, value in properties.items()
|
||||
if key in _mappings
|
||||
}
|
||||
return mappings_properties_builder(properties, _mappings)
|
||||
|
||||
Reference in New Issue
Block a user