Skip to content

Validate

Standard · 1 credit

Check whether a string is valid for a given format — from cron expressions to JSON Schema to semver.

FieldTypeRequiredDescription
typestringYesjson, yaml, toml, cron, json_schema, regex, semver, email, url
inputstringYesThe string to validate
optionsobjectNoType-specific options
FieldTypeDescription
validbooleanWhether the input passed validation
descriptionstringHuman-readable explanation
errorsarrayValidation errors — each has message, and optionally line, column, path
detailsobjectType-specific extra info
Terminal window
curl -X POST https://morso.dev/api/validate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "cron", "input": "*/5 * * * *"}'
{
"valid": true,
"description": "Every 5 minutes",
"errors": []
}
Terminal window
curl -X POST https://morso.dev/api/validate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "yaml", "input": "key: value\n bad indent"}'
{
"valid": false,
"description": "Invalid YAML",
"errors": [
{
"message": "mapping values are not allowed in this context",
"line": 2,
"column": 6
}
]
}
Terminal window
curl -X POST https://morso.dev/api/validate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "semver", "input": "1.2.3-beta.1"}'
{
"valid": true,
"description": "Valid semantic version",
"errors": []
}
Terminal window
curl -X POST https://morso.dev/api/validate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"type": "email", "input": "not-an-email@"}'
{
"valid": false,
"description": "Invalid email address",
"errors": [
{
"message": "missing domain after @"
}
]
}