fix(jambo): Add support for file-path format in StringTypeParser (#7)
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
from jambo.parser._type_parser import GenericTypeParser
|
||||
from jambo.types.type_parser_options import TypeParserOptions
|
||||
|
||||
from pydantic import EmailStr, HttpUrl, IPvAnyAddress
|
||||
from pydantic import EmailStr, HttpUrl, IPvAnyAddress, FilePath
|
||||
from typing_extensions import Unpack
|
||||
|
||||
from datetime import date, datetime, time
|
||||
@@ -28,6 +28,7 @@ class StringTypeParser(GenericTypeParser):
|
||||
"time": time,
|
||||
"date-time": datetime,
|
||||
"binary": bytes,
|
||||
"file-path": FilePath, # Added file-path format
|
||||
}
|
||||
|
||||
format_pattern_mapping = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from jambo.parser import StringTypeParser
|
||||
|
||||
from pydantic import EmailStr, HttpUrl, IPvAnyAddress
|
||||
from pydantic import EmailStr, HttpUrl, IPvAnyAddress, FilePath
|
||||
|
||||
from datetime import date, datetime, time
|
||||
from unittest import TestCase
|
||||
@@ -159,6 +159,18 @@ class TestStringTypeParser(TestCase):
|
||||
type_validator["pattern"], parser.format_pattern_mapping[format_type]
|
||||
)
|
||||
|
||||
def test_string_parser_with_file_path_format(self):
|
||||
parser = StringTypeParser()
|
||||
|
||||
properties = {
|
||||
"type": "string",
|
||||
"format": "file-path",
|
||||
}
|
||||
|
||||
type_parsing, type_validator = parser.from_properties("placeholder", properties)
|
||||
|
||||
self.assertEqual(type_parsing, FilePath)
|
||||
|
||||
def test_string_parser_with_unsupported_format(self):
|
||||
parser = StringTypeParser()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user