JSON Schema Validation

VerifiedSafe

Validates input data structure, types, and constraints using JSON schemas compliant with Draft 2020-12. Used when developing features like user registration, identity verification, or external API validation, providing detailed per-field error messages.

Sby Skills Guide Bot
DevelopmentIntermediate
6/2/2026
Claude CodeCursorWindsurfCopilotCodex
#json-schema#validation#schema-validation#identity-verification

Recommended for

Automated summary

A development guide for JSON Schema Validation to handle user registration, identity verification, and external API validation.

Strengths

  • Compliant with JSON Schema Draft 2020-12
  • Detailed per-field error messages
  • Supports tenant-specific custom schemas
  • Comprehensive coverage including E2E tests

Limitations

  • Tied to a specific Java implementation (JsonSchemaDefinition, JsonSchemaValidator)
  • Does not cover client-side validation or other languages
  • Schema examples are limited to a few use cases
When to use it

When you need to add or modify JSON Schema validation for user registration, identity verification, or external API in a Java application.

When not to use it

For simple validations without structured schemas, or when using a non-Java technology stack.

Security analysis

Safe
Quality score85/100

This skill is a development guide for JSON schema validation in a Java project. It contains no executable commands, no network calls, and no destructive operations. The provided code snippets and configuration are purely for documentation purposes.

No concerns found

How this analysis is made

Examples

Add user registration schema validation
Add JSON Schema validation for user registration with fields: email (format: email), name (string, 1-100 chars), and birthdate (pattern: YYYY-MM-DD). Use the existing JsonSchemaDefinition pattern from the codebase.
Implement identity verification schema
Create a JSON Schema for identity verification that accepts document_type (enum: passport, drivers_license, national_id) and document_number (string, minLength 5). Ensure the schema is Draft 2020-12 compliant.
Fix schema validation error handling
Improve error messages in JsonSchemaValidationException to include field-level details for missing required fields, type mismatches, and format violations.

name: spec-json-schema description: JSONスキーマ検証(JSON Schema Validation)機能の開発・修正を行う際に使用。ユーザー登録スキーマ、Identity Verificationスキーマ、外部API検証実装時に役立つ。

JSONスキーマ検証(JSON Schema Validation)開発ガイド

ドキュメント

  • documentation/docs/content_03_concepts/06-security-extensions/concept-03-schema-validation.md - JSONスキーマ検証概念

機能概要

JSONスキーマ検証は、入力データの構造・型・制約を検証する層。

  • JSON Schema Draft 2020-12準拠
  • ユーザー登録検証: テナント別カスタムスキーマ
  • Identity Verification検証: 本人確認申請データ検証
  • 外部API検証: リクエスト/レスポンス検証
  • 詳細エラーメッセージ: フィールド別エラー

モジュール構成

libs/
└── idp-server-platform/                     # プラットフォーム基盤
    └── .../platform/json/schema/
        ├── JsonSchemaDefinition.java       # スキーマ定義
        ├── JsonSchemaValidator.java        # スキーマ検証
        └── JsonSchemaValidationException.java

ユーザー登録でのスキーマ検証

idp-server-core/openid/identity/IdPUserCreator.java 内:

public class IdPUserCreator {

    JsonSchemaDefinition definition;
    AuthenticationInteractionRequest request;

    public User create() {
        User user = User.initialized();

        // スキーマ定義に基づいてフィールドを設定
        if (definition.hasProperty("name") &&
            request.containsKey("name")) {
            user.setName(request.getValueAsString("name"));
        }

        if (definition.hasProperty("email") &&
            request.containsKey("email")) {
            user.setEmail(request.getValueAsString("email"));
        }

        // その他のフィールドも同様に処理
        // ...

        return user;
    }
}

注意: JsonSchemaDefinitionが、許可されたフィールドを定義します。

スキーマ定義例

ユーザー登録スキーマ

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "email": {
      "type": "string",
      "format": "email"
    },
    "name": {
      "type": "string",
      "minLength": 1,
      "maxLength": 100
    },
    "birthdate": {
      "type": "string",
      "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}$"
    }
  },
  "required": ["email", "name"]
}

Identity Verification申請スキーマ

{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "type": "object",
  "properties": {
    "document_type": {
      "type": "string",
      "enum": ["passport", "drivers_license", "national_id"]
    },
    "document_number": {
      "type": "string",
      "minLength": 5
    }
  },
  "required": ["document_type", "document_number"]
}

スキーマ検証エラー

public class JsonSchemaValidationException {
    // フィールド別の詳細エラーメッセージ
    // - 必須フィールド不足
    // - 型不一致
    // - フォーマット違反
    // - 制約違反(minLength, maxLength, pattern等)
}

E2Eテスト

e2e/src/tests/
└── integration/ida/
    └── (Identity Verificationスキーマ検証テスト)

コマンド

# ビルド
./gradlew :libs:idp-server-platform:compileJava

# テスト
cd e2e && npm test -- integration/ida/

トラブルシューティング

スキーマ検証失敗

  • スキーマ定義が正しいか確認(JSON Schema Draft 2020-12形式)
  • 必須フィールドが含まれているか確認

型エラー

  • フィールドの型がスキーマと一致するか確認
  • string, number, boolean, object, arrayを正しく使用

フォーマット検証失敗

  • email, uri, date-time等のフォーマットが正しいか確認
  • カスタムpattern(正規表現)が正しいか確認

カスタムスキーマが反映されない

  • テナント別スキーマ設定が正しいか確認
  • JsonSchemaDefinitionが正しくロードされているか確認

From the file to a first result

The download contains exactly the content displayed on this page. This copy may differ from the latest version in the source repository.

View the source and supporting files

This download contains SKILL.md only. Any scripts, references, templates and dependencies are not included. Get the required files from the source, preserving their directory structure, before continuing.

1. Download the file

Download SKILL.md

From the root of a test project, save the file as .skill-downloads/json-schema-validation-mm5t89q1/SKILL.md, or use the command below. This folder is for inspecting the skill before installation.

Command for macOS/Linux or WSL: requires a POSIX shell and curl. On Windows without WSL, use the download button and create the folder manually.

mkdir -p '.skill-downloads/json-schema-validation-mm5t89q1' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/json-schema-validation-mm5t89q1/download' --output '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md.part' && mv '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md.part' '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md'

2. Check prerequisites

Read SKILL.md before using it. If it references scripts or external services, inspect them and prepare the required access in your test environment.

No recognized prerequisites section in this file. This does not mean it is self-contained: libraries, tools and access requirements may be mentioned elsewhere in the content or source repository.

The platforms on this page are catalog indications. The paths below follow tool documentation; they do not prove this skill has been run in those tools. No minimum tool version is confirmed for this listing.

3. Load the skill

After inspection, copy the complete folder into your project using one of the commands below, then open a new tool session. The command stops if a folder with the same name already exists: compare the files before replacing it.

Claude Code
test -f '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md' && test -s '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/spec-json-schema' && cp -R '.skill-downloads/json-schema-validation-mm5t89q1' '.claude/skills/spec-json-schema'

Cursor
test -f '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md' && test -s '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md' && mkdir -p '.cursor/skills' && test ! -e '.cursor/skills/spec-json-schema' && cp -R '.skill-downloads/json-schema-validation-mm5t89q1' '.cursor/skills/spec-json-schema'

Codex
test -f '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md' && test -s '.skill-downloads/json-schema-validation-mm5t89q1/SKILL.md' && mkdir -p '.agents/skills' && test ! -e '.agents/skills/spec-json-schema' && cp -R '.skill-downloads/json-schema-validation-mm5t89q1' '.agents/skills/spec-json-schema'

OpenSkills

OpenSkills must already be installed. The local install/read procedure is checked with OpenSkills 1.5.0, which requires Node.js ≥ 20.6.0. Catalog slugs are not resolved automatically.

Official OpenSkills installation
openskills install './.skill-downloads/json-schema-validation-mm5t89q1'

openskills read 'json-schema-validation-mm5t89q1'

Reading should display the installed file content and its base directory. It does not run the skill or install its dependencies.

For an agent that reads AGENTS.md, then sync the index. This command changes AGENTS.md: review the diff before using it.

openskills sync

Manual method or another tool: attach SKILL.md to a conversation, or open it in an agent that can read files. Include any required supporting resources. No universal folder is recognized by every tool.

4. Try a first task

Use a short, synthetic input: an API endpoint, a small document or an interface brief. In a new conversation, attach the file or give the agent its path, then adapt this request:

Read .skill-downloads/json-schema-validation-mm5t89q1/SKILL.md and apply its instructions to this example: [describe a test input]. Identify any missing files, dependencies or access. Produce the result requested by the skill without inventing data or running unreviewed scripts.

Expected result: output matching the skill instructions, or a precise list of missing prerequisites. A read confirmation alone does not validate a first use. If an external resource is unavailable, that path remains untested.

Related skills