In regex syntax, \s
is a metacharacter representing a whitespace (see Shorthand Character Classes). In some languages you need to double escape it because of the slash (so \\s
).
Lets analyze the regex:
^
is the begin of the string
\\s
is the space
+
is an operator meaning "one or more"
$
is the end of the string
So the pattern matches the strings composed only of at least one space and nothing more.
Let's now analyze the snippet:
"description"
is just the description associated to the translated_string
property
"type": "string"
means that in the JSON you can only use a string value for the translated_string
property
"not"
means that the following is not permitted:
"pattern": "^\\s+$"
is the regex above (so it must not be matched)
Note that the snippet is equivalent to:
"translated_string": {
"description": "A translated string",
"type": "string",
"not": {
"type": "string",
"pattern": "^\\s*$"
}
},
(where the *
operator means "zero or more")
or even simplier:
"translated_string": {
"description": "A translated string",
"type": "string",
"pattern": "^\\S+$"
},
(where \\S
is anything but a space)
So, the following JSON are correct:
"translated_string": "l"
"translated_string": " l"
"translated_string": " l "
"translated_string": " l "
While the following JSON are not correct:
"translated_string": ""
"translated_string": " "
"translated_string": " "
"translated_string": 1
"translated_string": [ SOMETHING ]
"translated_string": { SOMETHING }