From e12525ca9d070d3c607fb8b6a93ab0db509081ee Mon Sep 17 00:00:00 2001 From: Juan Cruz Viotti Date: Tue, 18 Nov 2025 11:10:03 -0400 Subject: [PATCH] Add a `single-line-text` utility schema Signed-off-by: Juan Cruz Viotti --- meta/schemas.json | 28 +-- schemas/misc/single-line-text.json | 15 ++ test/misc/single-line-text.test.json | 341 +++++++++++++++++++++++++++ 3 files changed, 359 insertions(+), 25 deletions(-) create mode 100644 schemas/misc/single-line-text.json create mode 100644 test/misc/single-line-text.test.json diff --git a/meta/schemas.json b/meta/schemas.json index b4b6605c..b23fa2d6 100644 --- a/meta/schemas.json +++ b/meta/schemas.json @@ -5,35 +5,13 @@ "properties": { "$id": false, "$comment": { - "$ref": "#/$defs/clean-prose" + "$ref": "../schemas/misc/single-line-text.json" }, "title": { - "$ref": "#/$defs/clean-prose" + "$ref": "../schemas/misc/single-line-text.json" }, "description": { - "$ref": "#/$defs/clean-prose" - } - }, - "$defs": { - "clean-prose": { - "type": "string", - "not": { - "anyOf": [ - { - "pattern": "\\.$" - }, - { - "pattern": " \\s" - }, - { - "pattern": "[\\n\\r\\t]" - }, - { - "pattern": "[\\x00-\\x1F\\x7F]" - } - ] - }, - "pattern": "^[^\\s].*[^\\s]$|^[^\\s]$" + "$ref": "../schemas/misc/single-line-text.json" } } } diff --git a/schemas/misc/single-line-text.json b/schemas/misc/single-line-text.json new file mode 100644 index 00000000..99267427 --- /dev/null +++ b/schemas/misc/single-line-text.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://json-schema.org/draft/2020-12/schema", + "title": "Single-line Text", + "description": "A string representing a single line of clean text without leading or trailing whitespace, excessive internal spacing, non-printable characters, newlines, tabs, trailing periods, or other punctuation issues", + "examples": [ + "This is a simple text", + "Multiple sentences work fine", + "Numbers and symbols: 123 $%&", + "Unicode characters are allowed: café, 日本語" + ], + "x-license": "https://github.com/sourcemeta/std/blob/main/LICENSE", + "x-links": [ "https://en.wikipedia.org/wiki/String_(computer_science)" ], + "type": "string", + "pattern": "^(?!.*\\.$)(?!.*(?