Skip to main content

date

Introduction

Verify whether the request parameter is in date format.

Example

Data Dictionary

hrm.salaries Human Resources System - Employee Salary Information Table

| Column name | Data type | Not empty | Increment | Key | Description | |-----------|---------|----|----|-------|--------- --| | emp_no | int(11) | Yes | - | Primary key, foreign key | Unique number of employee | | salary | int(11) | yes | - | - | employee's salary amount | | from_date | date | yes | - | primary key | start date of pay period | | to_date | date | is | - | - | The end date of the pay period |

In the above table, the start date from_date and end date to_date are both date type fields, and they need to comply with date specifications when writing.

ask

POST http://127.0.0.1:21000
Content-Type: application/json;charset=utf-8
{
"jsonrpc": "2.0",
"method": "hrm.salaries.add",
"params": {
"empNo": 10010,
"salary": 10001,
"fromDate": "2023-13-01",
"toDate": "2023-12-33"
},
"id": "client-unique-request-id"
}

Response

HTTP/1.1 400 Bad Request
Content-Type: application/json; charset=utf-8
{
"jsonrpc": "2.0",
"error": {
"code": -32602,
"message": "validating data type: fromDate: 2023-13-01 does not validate as date;toDate: 2023-12-33 does not validate as date",
"data": {
"errorCode": "EU.Validator.DataTypeError",
"errorDetails": [
{
"field": "fromDate",
"fieldValue": "2023-13-01",
"location": "hrm.salaries",
"message": "fromDate: 2023-13-01 does not validate as date",
"validator": "date"
},
{
"field": "toDate",
"fieldValue": "2023-12-33",
"location": "hrm.salaries",
"message": "toDate: 2023-12-33 does not validate as date",
"validator": "date"
}
],
"errorMessage": "fromDate: 2023-13-01 does not validate as date;toDate: 2023-12-33 does not validate as date"
}
},
"id": "client-unique-request-id"
}

Remarks: The above example was tested in Luwak 1.12.9.