Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:APIJSON APIJSON Operation Enum

From Leeroopedia
Knowledge Sources
Domains Validation, Request_Processing, DSL
Last Updated 2026-10-11 00:00 GMT

Overview

Java enum that defines the vocabulary of validation operations applied to request content, including MUST, REFUSE, TYPE, VERIFY, UNIQUE, EXIST, INSERT, UPDATE, REPLACE, and REMOVE.

Description

The Operation enum is the controlled vocabulary for request validation in APIJSON. Each constant represents a validation or data-manipulation operation that can be specified in the Request table's structure field. The OPERATION_KEY_LIST in AbstractVerifier enumerates all recognized operation keys.

Enum values and their structures:

  • MUST - String: "key0,key1,key2..." (required fields)
  • REFUSE - String: "key0,key1,key2..." (forbidden fields)
  • TYPE - Map: { "key0": "NUMBER", "key1": "STRING[]" } (type checking)
  • VERIFY - Map: { "phone~": "PHONE", "age{}": [0, 150] } (constraint checking)
  • EXIST - String: "key0,key1..." (existence check)
  • UNIQUE - String: "key0,key1..." (uniqueness check)
  • INSERT - Map: { "key0": value0 } (auto-insert values)
  • UPDATE - Map: { "key0": value0 } (auto-update values)
  • REPLACE - Map: { "key0": value0 } (replace if exists)
  • REMOVE - String: "key0,key1..." (remove if exists)
  • IF - Map: conditional script execution
  • ALLOW_PARTIAL_UPDATE_FAIL - String: batch partial failure tolerance
  • IS_ID_CONDITION_MUST - Boolean: force id condition requirement

Usage

Used by AbstractVerifier.verifyRequest() to parse and apply validation rules from the Request table. Not typically used directly by application code.

Code Reference

Source Location

  • Repository: APIJSON
  • File: src/main/java/apijson/orm/Operation.java

Signature

public enum Operation {
    MUST, REFUSE, TYPE, VERIFY, EXIST, UNIQUE,
    INSERT, UPDATE, REPLACE, REMOVE,
    IF, ALLOW_PARTIAL_UPDATE_FAIL, IS_ID_CONDITION_MUST
}

Import

import apijson.orm.Operation;

I/O Contract

Inputs

Name Type Required Description
(none) - - Enum has no runtime inputs; used as constants

Outputs

Name Type Description
values() Operation[] All enum constants
name() String Name of the constant (e.g., "MUST")

Usage Examples

Referencing Operations in Validation Config

// The Request table stores structure like:
// {
//   "MUST": "id,momentId,content",          // Operation.MUST
//   "REFUSE": "date",                         // Operation.REFUSE
//   "TYPE": { "momentId": "NUMBER" },        // Operation.TYPE
//   "VERIFY": { "content{}": ">0,<=500" },   // Operation.VERIFY
//   "UNIQUE": "username"                     // Operation.UNIQUE
// }

// In code, operation names are compared as strings:
if (key.equals(Operation.TYPE.name())) {
    // Process TYPE validation rule
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment