Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to validate personal email with json schema

Tags:

json

schema

The problem is i don't know how to validate personal email with Json Schema, what is the pattern for this ?

[email protected]

I already tried looking in google but cant find anything.

    "email": {
        "description": "Email of the user",
        "type": "string",
        "pattern": "",
    },
like image 724
Ricardo Alves Avatar asked Aug 20 '19 17:08

Ricardo Alves


People also ask

How do you validate a JSON Schema?

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).

Why can't I validate an email using the JSON API?

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.

What makes data valid according to a JSON-Schema?

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.

What is a valid JSON data type?

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.


1 Answers

You can use format to validate email in JSON Schema.

 "email": {
    "description": "Email of the user",
    "type": "string",
    "format": "email"
}
like image 182
ekansh Avatar answered Nov 15 '22 07:11

ekansh