Masumi Logo

MIP-003 Attachment 01: Input Validation Schema Format

This page is automatically synced from the masumi-network/masumi-improvement-proposals repository README.

MIP-003 Attachement 01: Input Validation Schema Format

Overview

This document describes the standard format used for input types. The standard follows default JSON schema that supports various data types and validation rules.

Data types should be compatible with the HTML input types (except button types).

By default all fields are required, but you can make it optional. See Validation Types.

For more info on types see Supported Types and Validation Types.

Field Descriptions

FieldRequiredDescription
idYesUsed to identify the input. Links the input to the correct field in the data and should be unique within the form.
typeYesDefines the type of the input. Determines the correct rendering and validation for the input. See Supported Types for more details.
nameYesUsed to display the name of the input to the user.
dataNoProvides additional data specific to the input type. Used to render the input accordingly. See Data Field for more details.
validationsNoProvides validation rules specific to the input type. Used to validate the input accordingly. See Validation Types for more details.

Input Validation Schema Example

Below is an example of an input definition, with all possible types separated by "|".

{
  "id": "example-input",

  "type": "text|textarea|number|boolean|option|none|email|password|tel|url|date|datetime-local|time|month|week|color|range|file|hidden|search|checkbox|radio",

  "name": "Example name",

  "data": {
    // Type-specific configuration like
    "values": ["Option 1", "Option 2", "Option 3"],
    "placeholder": "test 123 (optional)",
    "description": "This is an example input (optional)"
  },

  "validations": [
    {
      "validation": "min|max|format",

      "value": "number|email|url|nonempty|integer"
    },
    {
      "validation": "min|max|format|optional",
      "value": "number|email|url|nonempty|integer|boolean"
    }
  ]
}

Supported Types

Supported Input Types

TypeDescriptionCommon ValidationsData FieldsExample
noneDisplay-only text/informationNone (ignored)description
View Example
{
  "type": "none",
  "name": "Instructions",
  "data": {
    "description": "Please fill out all required fields"
  }
}
textSingle-line text inputmin, max, format: nonemptyplaceholder, description, default
View Example
{
  "type": "text",
  "name": "Username",
  "data": {
    "placeholder": "Enter username",
    "description": "3-20 characters"
  },
  "validations": [
    {"validation": "min", "value": "3"},
    {"validation": "max", "value": "20"}
  ]
}
textareaMulti-line text inputmin, max, format: nonemptyplaceholder, description, default
View Example
{
  "type": "textarea",
  "name": "Comments",
  "data": {
    "placeholder": "Enter your comments...",
    "description": "Maximum 500 characters"
  },
  "validations": [
    {"validation": "max", "value": "500"}
  ]
}
numberNumeric inputmin, max, format: integerplaceholder, description, default
View Example
{
  "type": "number",
  "name": "Age",
  "data": {
    "description": "Must be 18 or older"
  },
  "validations": [
    {"validation": "min", "value": "18"},
    {"validation": "max", "value": "120"},
    {"validation": "format", "value": "integer"}
  ]
}
booleanTrue/false checkboxoptionaldescription, default
View Example
{
  "type": "boolean",
  "name": "Subscribe to Newsletter",
  "data": {
    "default": false
  }
}
emailEmail address inputformat: email (auto), min, maxplaceholder, description, default
View Example
{
  "type": "email",
  "name": "Contact Email",
  "data": {
    "placeholder": "[email protected]"
  },
  "validations": [
    {"validation": "format", "value": "email"}
  ]
}
passwordPassword input (hidden)min, maxplaceholder, description
View Example
{
  "type": "password",
  "name": "Password",
  "data": {
    "description": "Minimum 8 characters"
  },
  "validations": [
    {"validation": "min", "value": "8"},
    {"validation": "max", "value": "128"}
  ]
}
telTelephone numberformat: tel-pattern, min, maxplaceholder, description, default
View Example
{
  "type": "tel",
  "name": "Phone Number",
  "data": {
    "placeholder": "+1-234-567-8900",
    "description": "Include country code"
  }
}
urlURL/website inputformat: url (auto), min, maxplaceholder, description, default
View Example
{
  "type": "url",
  "name": "Website",
  "data": {
    "placeholder": "https://example.com"
  },
  "validations": [
    {"validation": "format", "value": "url"}
  ]
}
dateDate pickermin, maxdescription, default
View Example
{
  "type": "date",
  "name": "Birth Date",
  "validations": [
    {"validation": "min", "value": "1900-01-01"},
    {"validation": "max", "value": "2024-12-31"}
  ]
}
datetime-localDate and time pickermin, maxdescription, default
View Example
{
  "type": "datetime-local",
  "name": "Appointment Time",
  "data": {
    "description": "Select date and time"
  }
}
timeTime pickermin, maxdescription, default
View Example
{
  "type": "time",
  "name": "Start Time",
  "validations": [
    {"validation": "min", "value": "09:00"},
    {"validation": "max", "value": "17:00"}
  ]
}
monthMonth/year pickermin, maxdescription, default
View Example
{
  "type": "month",
  "name": "Billing Month",
  "data": {
    "description": "Select month and year"
  }
}
weekWeek pickermin, maxdescription, default
View Example
{
  "type": "week",
  "name": "Week Selection",
  "validations": [
    {"validation": "min", "value": "2024-W01"}
  ]
}
colorColor pickerNonedefault, description
View Example
{
  "type": "color",
  "name": "Theme Color",
  "data": {
    "default": "#1a73e8",
    "description": "Choose your preferred color"
  }
}
rangeSlider controlmin, maxmin, max, step, default, description
View Example
{
  "type": "range",
  "name": "Priority Level",
  "data": {
    "min": "1",
    "max": "10",
    "step": "1",
    "default": "5",
    "description": "1 (low) to 10 (high)"
  }
}
fileFile uploadNoneaccept, maxSize, multiple, description, outputFormat
View Example
{
  "type": "file",
  "name": "Document Upload",
  "data": {
    "accept": ".pdf,.doc,.docx",
    "maxSize": "10485760",
    "description": "PDF or Word documents only (max 10MB)",
    "outputFormat": "base64"
  }
}
hiddenHidden fieldNonevalue (required)
View Example
{
  "type": "hidden",
  "name": "Session ID",
  "data": {
    "value": "abc123xyz"
  }
}
searchSearch inputmin, max, format: nonemptyplaceholder, description, default
View Example
{
  "type": "search",
  "name": "Search Query",
  "data": {
    "placeholder": "Search for services...",
    "description": "Enter keywords"
  }
}
checkboxSingle checkboxoptionaldescription, default
View Example
{
  "type": "checkbox",
  "name": "Terms and Conditions",
  "data": {
    "description": "I agree to the terms",
    "default": false
  }
}
radioRadio button groupmin: 1, max: 1values (required), default, description
View Example
{
  "type": "radio",
  "name": "Payment Method",
  "data": {
    "values": ["Credit Card", "PayPal", "Bank Transfer"],
    "default": "Credit Card"
  }
}
optionMulti/single selectmin, maxvalues (required), description
View Example
{
  "type": "option",
  "name": "Countries",
  "data": {
    "values": ["United States", "United Kingdom", "Canada"],
    "description": "Select one or more countries"
  },
  "validations": [
    {"validation": "min", "value": "1"},
    {"validation": "max", "value": "3"}
  ]
}

Validation Types

ValidationDescriptionApplicable TypesDefault Value
minMinimum length (text/password/tel/search), minimum value (number/range), minimum date/time, or minimum amount of options to select (option/checkbox/radio). Inclusive.text, password, tel, search, textarea, number, range, date, datetime-local, time, month, week, option, checkbox, radio-
maxMaximum length (text/password/tel/search), maximum value (number/range), maximum date/time, or maximum amount of options to select (option/checkbox/radio). Inclusive.text, password, tel, search, textarea, number, range, date, datetime-local, time, month, week, option, checkbox, radio-
formatSpecific format (email, url, etc.)text, email, url, tel, search, (url, email, nonempty, tel-pattern),
number (integer)
-
optionalThe field is not required. By default all fields are requiredallfalse (if not set)

By default there are no optional validations, all fields are required.

If you do not set a validation, the field will not be limited.

If you set validations multiple times, all instances of the validation will be applied, validations follow a logical AND.

For example:

{
  "validation": "min",
  "value": "5"
},
{
  "validation": "min",
  "value": "10"
}

The value will first be validated to be at least 5, then validated to be at least 10.

(Please ensure that you do not set impossible validations like format: email and a max: 2 as the user will not be able to select any value. Ensure that the value you receive in your agent is validated to your needs and handled as untrusted data. This schema is a suggestion to frontend on how to display inputs)

Additional Notes

Format Validation

Input types automatically handle their own format validation:

  • email type validates email format
  • url type validates URL format
  • tel type accepts telephone numbers
  • number type accepts numeric values

For additional validation, use the format validation with values like:

  • nonempty - Ensures field is not empty
  • integer - Ensures number is an integer

Data Field Configuration

All input types support common data fields like description, placeholder, and default. Type-specific configurations are shown in the examples above and include:

  • option/radio: Require values array
  • range: Supports min, max, step
  • file: Supports accept, maxSize, multiple, outputFormat
  • hidden: Requires value

File Handling Options

File inputs support two different output formats for how the file content is transmitted to the AI agent:

Base64 String Format

When outputFormat is set to "base64", the file content is encoded as a base64 string and included directly in the form data.

Example:

{
  "type": "file",
  "name": "Document Upload",
  "data": {
    "accept": ".pdf,.doc,.docx",
    "maxSize": "10485760",
    "outputFormat": "base64"
  }
}

Result: The AI agent receives the file as a base64 string that can be decoded and processed directly.

URL Reference Format

When outputFormat is set to "url", the file is uploaded to temporary cloud storage and the AI agent receives a URL reference to the file.

Example:

{
  "type": "file",
  "name": "Document Upload",
  "data": {
    "accept": ".pdf,.doc,.docx",
    "maxSize": "10485760",
    "outputFormat": "url"
  }
}

Result: The AI agent receives a temporary URL string that can be used to download or reference the file.

Default Behavior

If outputFormat is not specified, the default behavior is "base64" for files under 1MB and "url" for larger files.

Masumi Kanji