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

Resty-GWT MeduaType
How to evaluate a value as a variable in row returned by neo4j?
WSO2 ESB Custom Axis Module JSON Payload in MessageContext
Android - How can I access nested objects?
Json deserialization of Scala case objects with spray-json
JSON Structure/Syntax
What database model should be used with a bunch of different items?
JSON Property not binding to JSON.NET PropertyName in ASP.NET MVC 5 Post request
How to use Newtonsoft.Json as default in Asp.net Core Web Api?
Get product details in JSON format using REST API
Extract value from JSON
Get JSON stringify value
Express: Prevent bodyParser from parsing request
Nested arrays in json vs multiple separated json objects - performance
JSON object syntax
EXCEPTION: Response with status: 404 Not Found for URL / Angular2

Categories

HOME
python
jsf
admin-on-rest
wildcard
cpu-architecture
automated-tests
apache2
value
filter
tizen-wearable-sdk
onenote-api
structuremap
dropbox
uiactivityviewcontroller
iso
store
uiview
simple-injector
mousewheel
deb
richfaces
iis-10
katharsis
pipelinedb
ab-initio
bxslider
picturebox
graph-databases
reactivemongo
service-locator
openpgp
openshift-enterprise
bing-maps-api
.net-assembly
discord.net
ssh.net
google-account
pdftk
homekit
number-theory
web-deployment-project
sapui
jenkins-jira-trigger
spring-data-hadoop
volume
iphone-developer-program
jcreator
garrys-mod
efxclipse
hspec
aescryptoserviceprovider
slam-algorithm
cron-task
ruby-2.0
amf
emokit
twgl.js
handlebars.java
loopj
insertion-sort
data-import
vips
retro-computing
ipojo
findcontrol
coypu
adobe-indesign
subversion-edge
jython-2.7
sqoop2
ctrlp
client-side-validation
libssh2
mfmailcomposeviewcontroll
broadcasting
bounds
xenocode
lov
logentries
layered
sql-server-2012-web
dllexport
visual-studio-2003
phpsh
cadisplaylink
symfony-2.0
plone-funnelweb
hobo
driving-directions
msgbox
zookeeper
smooth
junit3
adobe-contribute
idictionary
grooveshark
scatterview
web-statistics
msf
hardware-infrastructure

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