- Schema Validation for YAML
- YAML - Red Hat
- vscode-yaml-validation
- Autocompletion not showing up with conditional subschemas #222
Create a regular expression for Cron statement
General Format
Field name | Mandatory? | Allowed values | Special characters |
---|---|---|---|
Seconds | No* | 0-59 | * / , - |
Minutes | Yes | 0-59 | * / , - |
Hours | Yes | 0-23 | * / , - |
Day of month | Yes | 1-31 | * / , - L W |
Month | Yes | 1-12 or JAN-DEC | * / , - |
Day of week | Yes | 0-6 or SUN-SAT | * / , - L # |
Year | No* | 1970–2099 | * / , - |
Predefined Scheduling Macros:
Entry | Equivalent to |
---|---|
@annually | 0 0 0 1 1 * * |
@yearly | 0 0 0 1 1 * * |
@monthly | 0 0 0 1 * * * |
@weekly | 0 0 0 * * 0 * |
@daily | 0 0 0 * * * * |
@hourly | 0 0 * * * * * |
@reboot |
Valid time units:
unit | definition |
---|---|
ns | nanosecond |
us, µs | microsecond |
ms | millisecond |
s | second |
m | minute |
h | hour |
Regex to allow only number between 1 to 12
Allowed values | Regex |
---|---|
0-59 | [1-5]?[0-9] |
0-23 | 2[0-3]|1[0-9]|[0-9] |
1-31 | 3[01]|[12][0-9]|[1-9] |
1-12 | 1[0-2]|[1-9] |
0-6 | [0-6] |
1970–2099 | 19[7-9][0-9]|20[0-9][0-9] |
Mapping to a schema defined in settings
"json.schemas": [
{
"fileMatch": [
"monitors.d/*.json"
],
"url": "./heartbeat-schema.json"
}
]
{ "$ref": "definitions.json#/address" }
JsonSchema - conditionally require attribute
Applying subschemas conditionally
"anyOf": [
{
"properties": { "type": { "const": "icmp" } },
"required": ["hosts"]
},
{
"properties": {
"controlType": {"const": "title"}
},
"required": ["controlType"]
},
{
"properties": {
"controlType": {"const": "button"}
},
"required": ["controlType"]
}
],
"allOf": [
{
"if": {
"properties": { "type": { "const": "icmp" } }
},
"then": {
"properties": {
"hosts": {"$ref": "#/definitions/hosts"},
"wait": {"$ref": "#/definitions/wait"}
}
}
},
{
"if": {
"properties": { "type": { "const": "tcp" } }
},
"then": {
"properties": {
"postal_code": { "pattern": "[A-Z][0-9][A-Z] [0-9][A-Z][0-9]" }
}
}
},
{
"if": {
"properties": { "type": { "const": "http" } }
},
"then": {
"properties": {
"postal_code": { "pattern": "[0-9]{4} [A-Z]{2}" }
}
}
}
],
"oneOf": [
{
"properties": {
"type": { "const": "icmp" },
"hosts": {"$ref": "#/definitions/hosts"},
"wait": {"$ref": "#/definitions/wait"}
}
},
{
"properties": {
"type": { "const": "tcp" },
"hosts": {"$ref": "#/definitions/hosts"}
}
},
{
"properties": {
"type": { "const": "http" },
"urls": {"$ref": "#/definitions/urls"}
}
}
],
{
"type": "string",
"format": "uri",
"pattern": "^(https?|wss?|ftp)://"
}
{
"type": "array",
"items": {
"type": "string"
}
}
{ "type": "string" }
"phone": {
"type": "string",
"pattern": "^(\\([0-9]{3}\\))?[0-9]{3}-[0-9]{4}$"
}
Annotate Enum Values with description
Instead of:
"enum": ["foo", "bar", "whatever"]
Do This:
"oneOf": [
{"const": "foo", "title": "Pick Foo"},
{"const": "bar", "title": "Pick Bar"},
{"const": "whatever", "title": "Don't Care"}
]
Make sure item property in array is unique in Json Schema?
Nope