Json Schema
We have design schema structure similer to json object send and receive from a API. Near about all properties define as json object type except 'options' & 'optionValue' metadata(sub-proerty), they have json array type.
By default all entity properties have required validation, it can be override using '__requiredAllExcept', '__required' or individually specify it property level. Property level settings always take precedence over global settings.
Example:{
"customer": { // entity name
"__requiredAllExcept": ["lastName"], // (version 1.1.0) optional entity level metadata for opt-out required validation.
or
"__required": ["firstName"], // (version 1.1.0) optional entity level metadata for opt-in required validation
"firstName": { // property name
"dataType": "string", // optional metadata from version 1.1.0 (earliar it was required)
"inputType": "text", // optional metadata
"dispalyName": "First Name" // optional metadata
},
"lastName": {}, // use empty property to apply defaults.
"address": {
"dataType": "group",
"inputType": "group",
"properties": {
"area": {
"dataType": "string"
},
"city": {
"dataType": "string",
"required": "required": true
}
...
}
}
...
},
"product": {
"productName": {
"dataType": "string"
},
productCode: {
"dataType": "string"
},
"category": {
"dataType": "number",
"inputType": "select",
"options": [ // options, optionValues or source any one is requried, if inputType is 'select'
{"description": "Samsung TV 51", "value": 125},
{"description": "LG Washing Machine 10kg", "value": 201},
{"description": "Sony Camera HXV3026" "value": 341}
]
or
// only for string dataType
"optionValues": ["Samsung TV 51", "LG Washing Machine 10kg", "Sony Camera HXV3026"]
or
"source": "http://schematocode.com/api/category" // any valid url
"descField": "name",
"valField": "code",
"parentObject": "cat" // only if expected data[] not at root level.
}
...
}
...
}
Entity
Entities are top level objects that should be unique entity name should be valid json identifier, it should be start with character and can contains characters, numbers and underscore only, it should not contain space or any special characters.
Properties
Properties are second level objects and it should also be unique name within entity and should be valid json identifier, it should be start with character and can contains characters, numbers and underscore only, it should not contains space or any special characters.
Metadata (sub-propertiies)
Metadata are predifined sub-proeprties, that help to generate input control and send data in specific data types. Some metadata are required and some are optional.
Required metadata
"key" : This metadata only required for primary / unique key property.
"options" or "optionValues" or "source", "descField" & "valField" only for "inputType" select, array->checkbox(checkbox group) and radio.
Optional metadata
"dataType" : Optional metadata from version 1.1.0, it was required earlier.
"displayName" : It will be use in grid/list component and will use for column name.
"format" : It will only applicable to date inputType.
"inputType" : Which form-control will be use for input data. If it is not provided then, it will be computed on base of dataType and other sub-properties(meta-data).
"label" : It will be use as lable for the form-control in input form. If it is not provided then displayName will be use.
"multiple" : It will store data as array instead of single value, it will be applicable only to select, file & image inputType.
"parentObject" : required only if descFiled and valField data not available at root level.
"position" : It will only applicable to checkbox inputType.
"rows" : It will only applicable to textarea inputType.
"step" : It will only applicable to number inputType.
"validation" & "hint" : It can be applicable to almost all inputTypes.
"value" : It will only applicable to checkbox inputType having string dataType.
Group
'group' inputType can be use to group multiple properties into one object. You need to use 'properties' sub-property(metadata) to define child properties same as top level properties.
You can use 'group' or 'array' as dataType and 'group' as inputType. In case of array it will be stored as array of group and having add/remove functionality.
Array
You can use 'array' dataType to stored data as string array, number array or group/object array.