Token导航 LogoToken导航TokenDH.com
研究检索操作浏览器github未标认证来源可访问许可证需确认审计通过

validating-json-datavalidating JSON 数据

Agent Skill

用于辅助数据整理、表格处理、CSV/Excel 分析、指标计算和图表准备。它适合让 Agent 清洗字段、汇总数据、发现异常、生成统计口径或把分析结果转成可读说明。使用时需要确认数据来源、字段含义和时间范围,避免把样本数据当全量事实;涉及敏感数据、导出文件或批量写回时,应先确认权限和脱敏边界。

总安装

1,670

周安装

71

GitHub Stars

342

下载量

585
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:validating-json-data(validating JSON 数据)
来源仓库:https://github.com/zaggino/z-schema
仓库路径:skills/validating-json-data
安装命令:
npx skills add https://github.com/zaggino/z-schema --skill validating-json-data
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/zaggino/z-schema --skill validating-json-data

简介

validating-json-data 辅助数据清洗、汇总与异常检测,支持 CSV/Excel 分析和图表准备。

  • 适合生成统计口径、转换分析结果为可读说明,需确认数据来源和时间范围。
  • 通过 GitHub 安装,使用 npx skills add 命令添加指定仓库的技能模块。
  • 涉及敏感数据或批量写回时应先确认权限和脱敏方式。
  • 适用宿主包括 Codex、Claude、Cursor、Gemini CLI,接入前应确认版本、权限和运行环境要求。

SKILL.md

Validating JSON Data with z-schema

z-schema validates JSON data against JSON Schema (draft-04, draft-06, draft-07, draft-2019-09, draft-2020-12). Default draft: draft-2020-12.

Quick start

import ZSchema from 'z-schema';

const validator = ZSchema.create();

const schema = {
  type: 'object',
  properties: {
    name: { type: 'string' },
    age: { type: 'integer', minimum: 0 },
  },
  required: ['name'],
};

// Throws on invalid data
validator.validate({ name: 'Alice', age: 30 }, schema);

Install: npm install z-schema

Choosing a validation mode

z-schema has four modes based on two toggles: async and safe. Pick the one that fits the use case.

ModeFactory callReturnsUse when
Sync throwZSchema.create()true or throws ValidateErrorDefault — simple scripts and middleware
Sync safeZSchema.create({safe: true}){valid, err?}Need to inspect errors without try/catch
Async throwZSchema.create({async: true})Promise<true> or rejectsUsing async format validators
Async safeZSchema.create({async: true, safe: true})Promise<{valid, err?}>Async + non-throwing

Sync throw (default)

import ZSchema from 'z-schema';

const validator = ZSchema.create();

try {
  validator.validate(data, schema);
} catch (err) {
  // err is ValidateError
  console.log(err.details); // SchemaErrorDetail[]
}

Sync safe

const validator = ZSchema.create({ safe: true });

const result = validator.validate(data, schema);
if (!result.valid) {
  console.log(result.err?.details);
}

Or call .validateSafe() on a regular (throwing) validator for the same result shape:

const validator = ZSchema.create();
const { valid, err } = validator.validateSafe(data, schema);

Async throw

Required when using async format validators.

const validator = ZSchema.create({ async: true });

try {
  await validator.validate(data, schema);
} catch (err) {
  console.log(err.details);
}

Async safe

const validator = ZSchema.create({ async: true, safe: true });

const { valid, err } = await validator.validate(data, schema);

Inspecting errors

ValidateError has .details — an array of SchemaErrorDetail:

interface SchemaErrorDetail {
  message: string; // "Expected type string but found type number"
  code: string; // "INVALID_TYPE"
  params: (string | number | Array<string | number>)[];
  path: string | Array<string | number>; // "#/age" or ["age"]
  keyword?: string; // "type", "required", "minLength", etc.
  inner?: SchemaErrorDetail[]; // sub-errors from anyOf/oneOf/not
  schemaPath?: Array<string | number>;
  schemaId?: string;
}

Example: walking nested errors

Combinators (anyOf, oneOf, not) produce nested inner errors:

const { valid, err } = validator.validateSafe(data, schema);
if (!valid && err) {
  for (const detail of err.details) {
    console.log(`${detail.path}: [${detail.code}] ${detail.message}`);
    if (detail.inner) {
      for (const sub of detail.inner) {
        console.log(`  └─ ${sub.path}: [${sub.code}] ${sub.message}`);
      }
    }
  }
}

Filtering errors

Pass ValidateOptions as the third argument to include or exclude specific error codes:

// Only report type errors
validator.validate(data, schema, { includeErrors: ['INVALID_TYPE'] });

// Suppress string-length errors
validator.validate(data, schema, { excludeErrors: ['MIN_LENGTH', 'MAX_LENGTH'] });

For the full error code list, see references/error-codes.md.

Schema pre-compilation

Compile schemas at startup for better runtime performance and to resolve cross-references:

const validator = ZSchema.create();

const schemas = [
  {
    id: 'address',
    type: 'object',
    properties: { city: { type: 'string' }, zip: { type: 'string' } },
    required: ['city'],
  },
  {
    id: 'person',
    type: 'object',
    properties: {
      name: { type: 'string' },
      home: { $ref: 'address' },
    },
    required: ['name'],
  },
];

// Compile all schemas (validates them and registers references)
validator.validateSchema(schemas);

// Validate data using a compiled schema ID
validator.validate({ name: 'Alice', home: { city: 'Paris' } }, 'person');

Remote references

Manual registration

ZSchema.setRemoteReference('http://example.com/schemas/address.json', addressSchema);
// or per-instance:
validator.setRemoteReference('http://example.com/schemas/person.json', personSchema);

Automatic loading via schema reader

import fs from 'node:fs';
import path from 'node:path';

ZSchema.setSchemaReader((uri) => {
  const filePath = path.resolve(__dirname, 'schemas', uri + '.json');
  return JSON.parse(fs.readFileSync(filePath, 'utf8'));
});

Diagnosing missing references

const { valid, err } = validator.validateSafe(data, schema);
if (!valid && err) {
  const missing = validator.getMissingReferences(err);
  const remote = validator.getMissingRemoteReferences(err);
}

Custom format validators

Global (shared across all validator instances)

ZSchema.registerFormat('postal-code', (value) => {
  return typeof value === 'string' && /^\d{5}(-\d{4})?$/.test(value);
});

Instance-scoped

const validator = ZSchema.create();
validator.registerFormat('postal-code', (value) => {
  return typeof value === 'string' && /^\d{5}(-\d{4})?$/.test(value);
});

Via options at creation time

const validator = ZSchema.create({
  customFormats: {
    'postal-code': (value) => typeof value === 'string' && /^\d{5}(-\d{4})?$/.test(value),
  },
});

Async format validators

Return Promise<boolean>. Requires {async: true}.

const validator = ZSchema.create({ async: true });
validator.registerFormat('user-exists', async (value) => {
  if (typeof value !== 'number') return false;
  const user = await db.findUser(value);
  return user != null;
});

Listing registered formats

const formats = ZSchema.getRegisteredFormats();

Choosing a draft version

Set the draft explicitly if the schema targets a specific version:

const validator = ZSchema.create({ version: 'draft-07' });

Valid values: 'draft-04', 'draft-06', 'draft-07', 'draft2019-09', 'draft2020-12' (default), 'none'.

For a feature comparison across drafts, see references/draft-comparison.md.

Common options

OptionDefaultPurpose
breakOnFirstErrorfalseStop validation at the first error
noEmptyStringsfalseReject empty strings as type string
noEmptyArraysfalseReject empty arrays as type array
strictModefalseEnable all strict checks at once
ignoreUnknownFormatsfalseSuppress unknown format errors (modern drafts always ignore)
formatAssertionsnullnull=always assert, true=respect vocabulary, false=annotation-only
reportPathAsArrayfalseReport error paths as arrays instead of JSON Pointer strings

For the full options reference, see references/options.md.

Validating sub-schemas

Target a specific path within a schema:

validator.validate(carData, fullSchema, { schemaPath: 'definitions.car' });

Browser usage (UMD)

<script src="node_modules/z-schema/umd/ZSchema.min.js"></script>
<script>
  var validator = ZSchema.create();
  try {
    validator.validate({ name: 'test' }, { type: 'object' });
  } catch (err) {
    console.log(err.details);
  }
</script>

TypeScript types

All types are exported from the package:

import type {
  JsonSchema, // Schema type (all drafts union)
  ZSchemaOptions, // Configuration options
  ValidateOptions, // Per-call options (schemaPath, includeErrors, excludeErrors)
  ValidateResponse, // { valid: boolean, err?: ValidateError }
  SchemaErrorDetail, // Individual error detail
  ErrorCode, // Error code string literal type
  FormatValidatorFn, // (input: unknown) => boolean | Promise<boolean>
  SchemaReader, // (uri: string) => JsonSchema
} from 'z-schema';

import { ValidateError } from 'z-schema';

Reference files

Important conventions

  • Always use ZSchema.create(options?) — never new ZSchema(). The factory returns the correctly typed variant.
  • Error details are on .details (not .errors).
  • Import types with import type {...} and values with import {ValidateError}.
  • Default draft is draft2020-12. Specify explicitly if targeting an older draft.

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

40%
按下载量换算234

Claude

27.6%
按下载量换算161

Cursor

18.76%
按下载量换算110

Gemini CLI

9.92%
按下载量换算58

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

操作浏览器

该 Skill 可能涉及浏览器控制能力,使用时可能读取或操作网页内容,需要在受控环境中确认权限边界。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills