-
317 input_str: The input string to extract from.
-
-
-
320 A tuple of the remaining string and the extracted schema instance, or `None` if extraction failed.
-
+
295 - the generated json could be invalid if the pattern allows invalid content between the json string's quotes.
+
296 - for example, `pattern=".*"` will allow '\"' to appear in the json string which is forbidden by JSON standard.
+
+
+
299 - Subclasses of collections.abc.Mapping[str,T] and typing.Mapping[str,T] where T is a supported type,
+
300 - Subclasses of collections.abc.Sequence[T] and typing.Sequence[T] where T is a supported type.
+
301 - tuple[T1,T2,...] where T1,T2,... are supported types. The order, type and number of elements will be preserved.
+
302 - typing.Literal[x1,x2,...] where x1, x2, ... are instances of int, string, bool or NoneType, or another typing.Literal[y1,y2,...]
+
303 - typing.Union[T1,T2,...] where T1,T2,... are supported types.
+
304 - schemas.Schema where all its fields' data types are supported. Recursive schema definitions are supported as well.
+
+
+
307 nonterminal: The nonterminal representing the extractor.
+
308 capture_name: The capture name of the extractor, or `None` if the extractor does not capture.
+
309 to_object: A callable to convert the extracted string to a schema instance.
+
+
311 super().
__init__(nonterminal, capture_name)
+
+
+
+
+
316 Extract a schema instance from a string.
+
+
+
+
319 input_str: The input string to extract from.
+
+
+
322 A tuple of the remaining string and the extracted schema instance, or `None` if extraction failed.
+
-
-
-
324 input_str = input_str.lstrip()
-
325 if not input_str.startswith((
'{',
'[')):
-
-
-
-
-
-
-
-
-
333 start_char = input_str[0]
-
334 end_char =
'}' if start_char ==
'{' else ']'
-
-
-
337 for char
in input_str:
-
-
339 if char == start_char:
-
-
341 elif char == end_char:
-
-
-
-
-
346 if char ==
'"' and not escape_next:
-
-
-
349 escape_next =
not escape_next
-
-
-
-
-
-
-
-
357 if bracket_count == 0
and not in_string:
-
-
-
-
-
362 json_str = input_str[:position]
-
363 remaining_str = input_str[position:]
-
-
365 return remaining_str, self.
_to_object(json_str)
-
-
-
-
-
-
-
+
+
+
326 input_str = input_str.lstrip()
+
327 if not input_str.startswith((
'{',
'[')):
+
+
+
+
+
+
+
+
+
335 start_char = input_str[0]
+
336 end_char =
'}' if start_char ==
'{' else ']'
+
+
+
339 for char
in input_str:
+
+
341 if char == start_char:
+
+
343 elif char == end_char:
+
+
+
+
+
348 if char ==
'"' and not escape_next:
+
+
+
351 escape_next =
not escape_next
+
+
+
+
+
+
+
+
359 if bracket_count == 0
and not in_string:
+
+
+
+
+
364 json_str = input_str[:position]
+
365 remaining_str = input_str[position:]
+
+
367 return remaining_str, self.
_to_object(json_str)
+
+
+
+
+
+
+
-
-
-
-
-
+
+
+
+
+
diff --git a/dev/json__schema_8py.html b/dev/json__schema_8py.html
index 4537f9f..0227a9c 100644
--- a/dev/json__schema_8py.html
+++ b/dev/json__schema_8py.html
@@ -169,11 +169,14 @@
|
typing.Type | formatron.schemas.json_schema._handle_literal (typing.Any literal, typing.Type obtained_type, dict[str, typing.Any] schema, dict[int, typing.Type] json_schema_id_to_schema) |
|
-
typing.Type | formatron.schemas.json_schema._create_custom_type (typing.Type|None obtained_type, dict[str, typing.Any] schema, dict[int, typing.Type] json_schema_id_to_schema) |
-
|
-
typing.Type | formatron.schemas.json_schema._handle_list_and_union (typing.Type obtained_type, dict[str, typing.Any] schema, dict[int, typing.Type] json_schema_id_to_schema) |
-
| Handle cases where the obtained type is a list or a union containing a list.
|
-
|
+
typing.Type | formatron.schemas.json_schema._handle_str_with_metadata (dict[str, typing.Any] schema) |
+
| Handle string type with metadata such as maxLength, minLength, and pattern.
|
+
|
+
typing.Type | formatron.schemas.json_schema._create_custom_type (dict[str, typing.Any] schema, dict[int, typing.Type] json_schema_id_to_schema) |
+
|
+
typing.Type | formatron.schemas.json_schema._handle_list_metadata (typing.Type obtained_type, dict[str, typing.Any] schema, dict[int, typing.Type] json_schema_id_to_schema) |
+
| Handle cases where the obtained type is a list.
|
+
|
typing.Type[typing.Any|None] | formatron.schemas.json_schema._obtain_type (dict[str, typing.Any] schema, dict[int, typing.Type] json_schema_id_to_schema) |
| Directly obtain type information from this schema's type keyword.
|
|
diff --git a/dev/json__schema_8py.js b/dev/json__schema_8py.js
index d6fcd5a..8f409e8 100644
--- a/dev/json__schema_8py.js
+++ b/dev/json__schema_8py.js
@@ -2,12 +2,13 @@ var json__schema_8py =
[
[ "formatron.schemas.json_schema.FieldInfo", "classformatron_1_1schemas_1_1json__schema_1_1FieldInfo.html", "classformatron_1_1schemas_1_1json__schema_1_1FieldInfo" ],
[ "_convert_json_schema_to_our_schema", "json__schema_8py.html#a5f4856cb7c30aa340432d386836f25be", null ],
- [ "_create_custom_type", "json__schema_8py.html#a38fed431c5191f57f9db65d4a744a96e", null ],
+ [ "_create_custom_type", "json__schema_8py.html#a15dc86b65c90ac8423c8989054f8c9e5", null ],
[ "_extract_fields_from_object_type", "json__schema_8py.html#af20251afc012b955e29c92922fcc83ef", null ],
[ "_get_literal", "json__schema_8py.html#a096ea829025ebd26b9ae165c17cf8976", null ],
[ "_handle_anyOf", "json__schema_8py.html#a6f88bf4e3c48d96b060ccdcbd80b3328", null ],
- [ "_handle_list_and_union", "json__schema_8py.html#aa83ea66f3e98cec63e9ff7d2788345af", null ],
+ [ "_handle_list_metadata", "json__schema_8py.html#aa80f28ccaf9ed4b404564f629139f9d1", null ],
[ "_handle_literal", "json__schema_8py.html#a969bd30894a578428528b94b0f82f1ba", null ],
+ [ "_handle_str_with_metadata", "json__schema_8py.html#a32e51b70be50d55d3944e6c700bbd1a5", null ],
[ "_infer_type", "json__schema_8py.html#ac742e1e581efccb6cc9742e7a23c25c2", null ],
[ "_merge_key", "json__schema_8py.html#a5fcddd43a5f64374b5b75d4aafeb9135", null ],
[ "_merge_referenced_schema", "json__schema_8py.html#a45c9b97319a58c2013b8e3f10ad78c30", null ],
diff --git a/dev/json__schema_8py_source.html b/dev/json__schema_8py_source.html
index b2bfa9b..e385fd9 100644
--- a/dev/json__schema_8py_source.html
+++ b/dev/json__schema_8py_source.html
@@ -179,300 +179,324 @@
51 for data validation and serialization. Currently, only the following JSON Schema features are supported:
-
-
55 - `properties` keyword
-
56 - Due to implementation limitations, we always assume `additionalProperties` is false.
-
57 - `enum` and `const` keyword
+
54 - `minLength, maxLength, pattern` keywords for string type
+
+
56 - `properties` keyword
+
57 - Due to implementation limitations, we always assume `additionalProperties` is false.
-
58 - This includes advanced enum types such as array and object.
-
59 - Note that if both `enum`(or `const`) and `type` are present, `type` will be ignored.
-
+
58 - `enum` and `const` keyword
+
59 - This includes advanced enum types such as array and object.
+
60 - Note that if both `enum`(or `const`) and `type` are present, `type` will be ignored.
-
-
62 - This currently does not support factoring out common parts of the subschemas(like https://json-schema.org/understanding-json-schema/reference/combining#factoringschemas)
+
+
-