TIMESTAMP
Introduction
Verify whether the parameter value is in date and time format
Example
Tested on Luwak 1.11
Data Dictionary
hrm.sys_tasks Human Resources System - System Task List
| Column name | Data type | Not empty | Increment | Key | Description | |------------|-------------|----|----|----|------ --| | id | int(11) | yes | yes | primary key | - | | title | varchar(255) | Yes | - | - | Task title | | completed | tinyint(1) | - | - | - | Whether the task is completed | | start_time | timestamp | - | - | - | Task start time | | end_time | timestamp | - | - | - | Task end time |
-
Create hrm.sys_tasks task table
DROP TABLE IF EXISTS hrm.sys_tasks;
CREATE TABLE hrm.sys_tasks
(
id INT PRIMARY KEY AUTO_INCREMENT,
title VARCHAR(255) NOT NULL,
completed BOOLEAN COMMENT '0 not completed 1 completed data_type=bool',
start_time TIMESTAMP,
end_time TIMESTAMP
); -
Table comment
data_type=bool
means1
,0
is allowed
Parameter mapping and verification
Verification rules
- completed can only be the number 1 or 0
- title required
- id is optional, if id is passed, refer to the primary key constraint
- start_time is the date and time, such as "2023-11-01 08:00:00"
- end_time is the date and time, such as "2023-11-01 09:00:00"
ask
POST http://127.0.0.1:21000
Content-Type: application/json;charset=utf-8
{
"jsonrpc": "2.0",
"method": "hrm.sysTasks.add",
"params": {
"title": "testing timestamp type",
"completed": 1,
"startTime": "2023-11-01",
"endTime": "2023-11-01"
},
"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: endTime: 2023-11-01 does not validate as timestamp;startTime: 2023-11-01 does not validate as timestamp",
"data": {
"errorCode": "EU.Validator.DataTypeError",
"errorDetails": [
{
"field": "startTime",
"fieldValue": "2023-11-01",
"location": "hrm.sys_tasks",
"message": "startTime: 2023-11-01 does not validate as timestamp",
"validator": "timestamp"
},
{
"field": "endTime",
"fieldValue": "2023-11-01",
"location": "hrm.sys_tasks",
"message": "endTime: 2023-11-01 does not validate as timestamp",
"validator": "timestamp"
}
],
"errorMessage": "endTime: 2023-11-01 does not validate as timestamp; startTime: 2023-11-01 does not validate as timestamp"
}
},
"id": "client-unique-request-id"
}
Remarks: The above example was tested in Luwak 1.12.9.