138 lines
3.0 KiB
JSON
138 lines
3.0 KiB
JSON
[
|
|
{
|
|
"description": "minLength validation",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "minLength_0_0",
|
|
"schemas": {
|
|
"minLength_0_0": {
|
|
"minLength": 2
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "longer is valid",
|
|
"data": "foo",
|
|
"schema_id": "minLength_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "exact length is valid",
|
|
"data": "fo",
|
|
"schema_id": "minLength_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "too short is invalid",
|
|
"data": "f",
|
|
"schema_id": "minLength_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MIN_LENGTH_VIOLATED",
|
|
"values": {
|
|
"count": "1",
|
|
"limit": "2"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "minLength_0_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
},
|
|
{
|
|
"description": "ignores non-strings",
|
|
"data": 1,
|
|
"schema_id": "minLength_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "one grapheme is not long enough",
|
|
"data": "💩",
|
|
"schema_id": "minLength_0_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MIN_LENGTH_VIOLATED",
|
|
"values": {
|
|
"limit": "2",
|
|
"count": "1"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "minLength_0_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"description": "minLength validation with a decimal",
|
|
"database": {
|
|
"types": [
|
|
{
|
|
"name": "minLength_1_0",
|
|
"schemas": {
|
|
"minLength_1_0": {
|
|
"minLength": 2
|
|
}
|
|
}
|
|
}
|
|
]
|
|
},
|
|
"tests": [
|
|
{
|
|
"description": "longer is valid",
|
|
"data": "foo",
|
|
"schema_id": "minLength_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": true
|
|
}
|
|
},
|
|
{
|
|
"description": "too short is invalid",
|
|
"data": "f",
|
|
"schema_id": "minLength_1_0",
|
|
"action": "validate",
|
|
"expect": {
|
|
"success": false,
|
|
"errors": [
|
|
{
|
|
"code": "MIN_LENGTH_VIOLATED",
|
|
"values": {
|
|
"count": "1",
|
|
"limit": "2"
|
|
},
|
|
"details": {
|
|
"path": "",
|
|
"schema": "minLength_1_0"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
}
|
|
]
|
|
}
|
|
] |