Implementation:APIJSON APIJSON AbstractVerifier verifyRequest
| Knowledge Sources | |
|---|---|
| Domains | Security, Validation, Request_Processing |
| Last Updated | 2026-10-11 00:00 GMT |
Overview
Concrete request validation method that checks request content against configurable rules (MUST, REFUSE, TYPE, VERIFY, UNIQUE, EXIST) loaded from the Request table, provided by the APIJSON ORM framework.
Description
The verifyRequest method on AbstractVerifier validates request content against rules defined in the Request database table. The Request table stores per-method, per-tag validation configurations including:
- MUST: Required fields that must be present
- REFUSE: Fields that are not allowed
- TYPE: Type validation for each field (BOOLEAN, NUMBER, STRING, URL, DATE, ARRAY, etc.)
- VERIFY: Conditional validation (regex patterns, range checks, length constraints)
- UNIQUE: Uniqueness checks (field must not already exist)
- EXIST: Existence checks (field must already exist)
- INSERT/UPDATE/REPLACE/REMOVE: Data manipulation rules
The method uses REQUEST_MAP (keyed by method tag, versioned) to look up the validation config for the current request. It is called during parseCorrectRequest() which is invoked from onVerifyContent().
Usage
Called internally by the framework during content verification. Configure validation rules by inserting records into the Request table. Override in a subclass to add custom validation logic.
Code Reference
Source Location
- Repository: APIJSON
- File: src/main/java/apijson/orm/AbstractVerifier.java
Signature
// Instance method
public M verifyRequest(
@NotNull RequestMethod method, String name, M target, M request, int maxUpdateCount,
String database, String datasource, String namespace, String catalog, String schema
) throws Exception
// Static overloads (multiple parameter combinations)
public static <T, M extends Map<String, Object>, L extends List<Object>> M verifyRequest(
@NotNull final RequestMethod method, final String name, final M target, final M request,
final int maxUpdateCount, @NotNull Parser<T, M, L> parser
) throws Exception
public static <T, M extends Map<String, Object>, L extends List<Object>> M verifyRequest(
@NotNull RequestMethod method, String name, M target, M request, int maxUpdateCount,
String database, String datasource, String namespace, String catalog, String schema,
final IdCallback<T> idCallback, @NotNull Parser<T, M, L> parser
) throws Exception
Parameters:
- method - HTTP method (POST/PUT/DELETE)
- name - Tag or table name for REQUEST_MAP lookup
- target - Target structure from Request table config
- request - Actual request map to validate
- maxUpdateCount - Maximum batch update count
- database/datasource/namespace/catalog/schema - DB connection params
Returns: M - Validated request map with MUST/REFUSE/TYPE/VERIFY checks applied
Import
import apijson.orm.AbstractVerifier;
import apijson.orm.Operation;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| method | RequestMethod | Yes | HTTP method |
| name | String | Yes | Tag/table name for REQUEST_MAP lookup |
| target | M | Yes | Target structure from Request config |
| request | M | Yes | Actual request to validate |
| maxUpdateCount | int | Yes | Max batch update size |
| REQUEST_MAP | Map<String,SortedMap<Integer,Map<String,Object>>> | Yes | Validation configs from Request table |
Outputs
| Name | Type | Description |
|---|---|---|
| return | M | Validated request map |
Usage Examples
Request Table Configuration
// Request table record for POST Comment:
// {
// "method": "POST",
// "tag": "Comment",
// "structure": {
// "MUST": "id,momentId,content",
// "REFUSE": "date",
// "TYPE": { "momentId": "NUMBER", "content": "STRING" },
// "VERIFY": { "content{}": ">0,<=500" }
// }
// }
// During request processing:
// verifyRequest(POST, "Comment", target, request, 10, db, ds, ns, cat, schema)
// Validates:
// 1. id, momentId, content are present (MUST)
// 2. date is not present (REFUSE)
// 3. momentId is a NUMBER, content is a STRING (TYPE)
// 4. content length is 1-500 characters (VERIFY)
Operation Enum Values
// Operation enum defines all validation operations:
// MUST - "id,name,userId" (required fields)
// REFUSE - "adminFlag" (forbidden fields)
// TYPE - { "id": "NUMBER", "tags": "STRING[]" }
// VERIFY - { "phone~": "PHONE", "age{}": [0, 150] }
// UNIQUE - "username,email" (must not exist)
// EXIST - "userId" (must exist in referenced table)
// INSERT - { "createTime": "now()" } (auto-set on insert)
// UPDATE - { "updateTime": "now()" } (auto-set on update)