How does Angular Schema Form work?

Viewed 1032

Why does Angular Schema Form have both a json form and a json schema that are separate? It seems that some of the properties in the form could be in the schema and vice-versa. For example, in the simple example on the schemaform.io website we have the form as:

[
  "name",
  "email",
  {
    "key": "comment",
    "type": "textarea",
    "placeholder": "Make a comment"
  },
  {
    "type": "submit",
    "style": "btn-info",
    "title": "OK"
  }
]

And the schema as:

{
  "type": "object",
  "title": "Comment",
  "properties": {
    "name": {
      "title": "Name",
      "type": "string"
    },
    "email": {
      "title": "Email",
      "type": "string",
      "pattern": "^\\S+@\\S+$",
      "description": "Email will be used for evil."
    },
    "comment": {
      "title": "Comment",
      "type": "string",
      "maxLength": 20,
      "validationMessage": "Don't be greedy!"
    }
  },
  "required": [
    "name",
    "email",
    "comment"
  ]
}

It seems that in the email property in the schema both the title and the description could just as well be in the form definition as in the schema. Can someone explain the meaning of both the form and the schema and why they are separate?

1 Answers
Related