Skip to main content

int

Introduction

Verify whether the request parameter is an integer.

Integers can be zero, positive, and negative, such as 1, 100, 0, -10.

Example

Tested on Luwak 1.11

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 |

Parameter mapping and verification

Convert the camel case starting from lower case of the parameter field to lower case and underscore, and map it to the column

Verification rules

  • The employee number is an integer
  • Salary is an integer
  • The start date conforms to the date specification, such as the month cannot be 13 and the date cannot be 32
  • The end date conforms to the date specification
  • The combination of employee number and start date should not exist in the table, refer to the unique constraint
  • The employee number exists in the employee table, refer to the foreign key constraint

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": "10000a",
"fromDate": "2023-10-01",
"toDate": "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: salary: 10000a does not validate as numeric",
"data": {
"errorCode": "EU.Validator.DataTypeError",
"errorDetails": [
{
"field": "salary",
"fieldValue": "10000a",
"location": "hrm.salaries",
"message": "salary: 10000a does not validate as numeric",
"validator": "numeric"
}
],
"errorMessage": "salary: 10000a does not validate as numeric"
}
},
"id": "client-unique-request-id"
}

Remarks: The above example was tested in Luwak 1.12.9.