Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Proposed Form Format

Expand
titleJSON Object
Code Block
languagejson
{
  "schemaName": "user",
  "schemaVersion": 2,
  "schema": {
    "type": "object",
    "required": ["name", "gender", "dateOfBirth"],
    "properties": {
      "name": {
        "type": "string",
        "minLength": 2,
        "maxLength": 20,
        "hint": "Name",
        "value": "Ajil",
        "nullable": false,
        "defaultValue": "'NA'"
      },
      "gender": {
        "type": "string",
        "enum": ["Male", "Female", "Others", "Not specified"],
        "hint": "Gender",
        "value": "Male",
        "nullable": false,
        "defaultValue": "'Not specified'",
      },
      "dateOfBirth": {
        "type": "string",
        "format": "date",
        "hint": "Date of Birth",
        "firstDate": "1920-01-01",
        "value": "1992-09-29T00:00:00.000",
        "nullable": true,
      },
      "dateOfRegistration": {
        "type": "string",
        "format": "date",
        "hint": "Date of registration",
        "firstDate": "1920-01-01",
        "nullable": true,
      },
      "isHead": {
        "type": "boolean",
        "hint": "Household Head",
        "nullable": false,
        "defaultValue": 1,
      },
      "linkHousehold": {
        "type": "boolean",
        "hint": "Link with household",
        "nullable": false,
        "defaultValue": 1,
      },
      "household": {
        "type": "string",
        "enum": [
          "A",
          "B",
          "C",
          "D",
          "E",
        ],
        "hint": "Household ID",
        "nullable": true,
        "displayBehavior": {
          "behavior": "hide",
          "oneOf": ["isHead", "linkHousehold"],
        },
      },
    }
  },
  "actionSchema": [
    {
      'name': 'reset',
      'buttonType': 'text',
      'buttonName': 'Reset',
      "actionItems": [
        {"type": "reset"}
      ],
    },
    {
      'name': 'submit',
      'buttonName': 'Submit',
      "actionItems": [
        {
          "type": "api",
          "urlSchema": {"method": "post", "urlSchema": ""},
        },
        {
          "type": "navigate",
          "routingSchema": {"destination": "forms/delivery"},
        },
      ],
    },
  ]
}

Structure

Schema Object

Code Block
{
  "schemaName": "householdRegistration",
  "schemaVersion": "1.0.0",
  "schema": { ... }, // Possibly rename to property schema
  "actionSchema": { ... }
}

The schemaName is used to identify the form to be displayed on upcoming pages after navigation. The schemaVersion will be used to update/create existing stored schema.

Property Schema

ExpandtitleJSON Object

Code Block
{
  "type": "object",
  "required": ["name", "gender", "dateOfBirth"],
  "properties": {
    "name": {
      "type": "string",
      "minLength": 2,
      "maxLength": 20,
      "hint": "Name",
      "value": "Ajil",
      "nullable": false,
      "defaultValue": "'NA'"
    },
    "gender": {
      "type": "string",
      "enum": ["Male", "Female", "Others", "Not specified"],
      "hint": "Gender",
      "value": "Male",
      "nullable": false,
      "defaultValue": "'Not specified'",
    },
    "dateOfBirth": {
      "type": "string",
      "format": "date",
      "hint": "Date of Birth",
      "firstDate": "1920-01-01",
      "value": "1992-09-29T00:00:00.000",
      "nullable": true,
    },
    "dateOfRegistration": {
      "type": "string",
      "format": "date",
      "hint": "Date of registration",
      "firstDate": "1920-01-01",
      "nullable": true,
    },
    "isHead": {
      "type": "boolean",
      "hint": "Household Head",
      "nullable": false,
      "defaultValue": 1,
    },
    "linkHousehold": {
      "type": "boolean",
      "hint": "Link with household",
      "nullable": false,
      "defaultValue": 1,
    },
    "household": {
      "type": "string",
      "enum": [
        "A",
        "B",
        "C",
        "D",
        "E",
      ],
      "hint": "Household ID",
      "nullable": true,
      "displayBehavior": {
        "behavior": "hide",
        "oneOf": ["isHead", "linkHousehold"],
      },
    },
  }
}

The property schema determines the fields that appear in the form and specifies the validation and display criteria.

TextField

  • type: string

DatePicker

  • type: string

  • format: date

DateTimePicker

  • type: string

  • format: datetime

NumberTextField

  • type: integer/double

FilePicker

  • type: string

  • format: fileUrl

Switch/Checkbox

  • type: boolean

  • format: Switch/Checkbox

DropdownField

  • type: string

  • format: dropdown

  • enums: string[]

CheckboxGroup

  • type: string[]

  • enums: string[]

NumberSpinner

  • type: integer/double

  • increment: integer/double

RadioGroup

  • type: string

  • format: radio

  • enums: string[]

Validators

The following validators are supported

  • minLength/maxLength

  • min/max:

  • required