The problem is i don't know how to validate personal email with Json Schema, what is the pattern for this ?
I already tried looking in google but cant find anything.
"email": {
"description": "Email of the user",
"type": "string",
"pattern": "",
},
Introducing JSON Schema A much simpler way to maintain both types and validation within a project is to use a single source of truth. The main option for this is JSON Schema. A JSON Schema file allows you to define types using a JSON file, using a specification defined by the selected draft (at the time of writing it’s number 7).
If you pass this to your server side API using the JSON API plugin, you can't validate it on the server to determine if it's valid. Take a look at how I build this email validation using Glitch and a Node.js Express web server together with Chatfuel's JSON API.
You may expect that to be valid according to such schema, the data must be a string matching the pattern: But the JSON-schema standard specifies that if a keyword doesn’t apply to the data type, then the data is valid according to this keyword.
But the JSON-schema standard specifies that if a keyword doesn’t apply to the data type, then the data is valid according to this keyword. That means that any data that is not of type “string” is valid according to the schema above—numbers, arrays, objects, boolean, and even null.
You can use format to validate email in JSON Schema.
"email": {
"description": "Email of the user",
"type": "string",
"format": "email"
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With