json


Json schema regex


I am building a json request schema at the moment. One of my constraints in the schema is that there value of firstLetter should ONLY contain 1 character, lowercase or uppercase. I tried the following (its a snippet of the schema):
"firstLetter": {
"id": "/properties/firstLetter",
"maxLength": 1,
"minLength": 1,
"pattern": "[a-z][A-Z]",
"type": "string"
}
but it doesn't seem to work. I would also like the regex to have the rule that there should only be 1 character
Acc. to 6.8. pattern section of JSON Schema Validation: A Vocabulary for Structural Validation of JSON:
The value of this keyword MUST be a string. This string SHOULD be a valid regular expression, according to the ECMA 262 regular expression dialect.
A string instance is considered valid if the regular expression matches the instance successfully. Recall: regular expressions are not implicitly anchored.
You may use
"pattern": "^[a-zA-Z]$"
It will match exactly 1-letter strings, only consisting of an ASCII letter.
Note that maxLength and minLength become redundant with this regex validation, so you may minify the code to
"firstLetter": {
"id": "/properties/firstLetter",
"pattern": "^[a-zA-Z]$",
"type": "string"
}

Related Links

SQLite extension binaries
How to get specific value from JSON in swift
Parsing object having property of type string that contains double quotes in it
Golang & mgo: How to create a generic entity with common fields like _id, creation time, and last update
Unexpected error within json babel 6.9
ASP.Net MVC how to display linq query data to an string array in view [duplicate]
How to create custom key in json response using golang
Convert JSON to Avro schema in Nodejs
restify jsonClient failing at post
Kendo Grid Date Filter wont work with my JSON data
JSONArray parsing laravel 4
How to manipulate native Json in WSO2 ESB?
How to read html entities using json response in Symfony2
Razor if statement with JSON [duplicate]
jSon script not displaying the table content
How to make Flask parse numbers in POSTed JSON data?

Categories

HOME
python
sas
oauth
steam
extract
chaiscript
snap.svg
xcode8.3
shader
eval
cs-cart
simple-injector
dendrogram
python-unicode
saiku
prestodb
vs2017
sonarqube-msbuild-runner
nmake
excel-2010
facebook4j
k2
header-files
pipelinedb
superagent
superscript
red-black-tree
ioc-container
expand
recurrence-relation
large-data
bigcartel
es-shell
parse-android-sdk
mediawiki-extensions
react-native-router-flux
pdftk
lftp
php-ews
w3-total-cache
nsjsonserialization
drawingarea
appstore-approval
gauss
azureportal
libtiff.net
verbose
glkit
galleriffic
audioqueue
mix
tuxedo
contour
distribute
spinlock
group-concat
axes
bluesnap
magento-1.4
void
android-recyclerview
jenkins-scriptler
document-oriented-db
insert-into
wikitext
oai
retro-computing
sevenzipsharp
shift-jis
chaining
dache
adaptive-compression
smartystreets
map-force
reserved-words
hamsterdb
arangodb-php
pyjade
jquery-tabs
gamepad
trimming
jqmobi
justgage
nuspec
resgen
awesomeprint
arbor.js
xml-libxml
cgpath
crocodoc
moq-3
ninject-extensions
text-size
scraperwiki
coff
paintcomponent
for-xml-path
msn
camtasia
kpi
project-lifecycle
self-reference

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App