ajv-data-validate

Validate customer JSON structures with AJV to catch missing fields and type errors. Intended for scenarios that require JSON Schema validation, AJV checks, or structural checks before form submission.

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "ajv-data-validate" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-2e0ceefdbafd3282a01e177c7877069dac4635318d8122e66f46eef8050e38f8. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/tkpn2026756 before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Validate customer JSON structures with AJV to catch missing fields and type errors. Intended for scenarios that require JSON Schema validation, AJV checks, or structural checks before form submission.

0 Downloads

Introduction source: third_party · user_f1b049da · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: ajv-data-validate
slug: tkpn2026756
displayName: Schema数据校验
version: 1.0.0
summary: 用 AJV 校验客户 JSON 数据结构,拦截缺字段与类型错误。
license: MIT
description: 用 AJV 校验客户 JSON 数据结构,拦截缺字段与类型错误。当用户需要 JSON Schema 校验、AJV、表单提交前结构检查时使用。

Schema 数据校验(AJV)

灵感:能力工具箱 ajv-schema(pkg: ajv)。

在保存/导入客户 JSON 前,用 JSON Schema + AJV 做本地校验,返回可读中文错误列表。

何时使用

  • 导入客户 JSON / 接口载荷自检
  • 动态表单提交前结构校验

硬约束

  1. 使用 ajv(建议 Ajv2020 或项目既有大版本,文档写明)。
  2. Schema 与数据均为纯 JSON;校验失败返回 errors[](路径 + 信息),禁止只抛英文堆栈。
  3. 常见规则示例:必填 name、mobile 模式、枚举阶段等;可替换业务 Schema。
  4. allErrors: true 以便一次列出多处问题(可配置)。
  5. 不发起网络请求;Schema 内 $ref 远程地址默认禁用或明确警告。

推荐实现要点

import Ajv from 'ajv'

const ajv = new Ajv({ allErrors: true, strict: false })

export const customerSchema = {
  type: 'object',
  additionalProperties: true,
  required: ['name'],
  properties: {
    name: { type: 'string', minLength: 1 },
    mobile: { type: 'string', pattern: '^1\\d{10}$' },
    stage: { type: 'string', enum: ['lead', 'contact', 'intend', 'negotiate', 'won', 'lost'] },
  },
} as const

export function validateCustomer(data: unknown) {
  const validate = ajv.compile(customerSchema)
  const ok = validate(data)
  if (ok) return { ok: true as const, errors: [] as string[] }
  const errors = (validate.errors || []).map((e) => {
    const path = e.instancePath || '/'
    return `${path} ${e.message || 'invalid'}`
  })
  return { ok: false as const, errors }
}

Agent 步骤

  1. 接入 AJV + 业务 Schema;错误文案可映射中文。
  2. 自测:缺 name、错误手机号应失败;合法对象通过。
  3. UI:错误列表贴近字段展示。

附加

Current listing version

1.0.0

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value82/100

Highlights

  • 提供 JSON Schema 校验能力,适用于表单提交前结构检查、接口载荷自检等明确业务场景
  • 具备拦截缺失字段与类型错误的实际价值,属于通用工具范畴
Trigger Precision85/100

Highlights

  • description 明确描述了使用场景,触发词覆盖合理,边界清晰
Structure and Standards75/100

Areas to improve

  • 缺少端到端用户示例 Reported severity: Minor

    文档结构清晰,但缺少一个完整的端到端用户操作示例

    Recommendation: 建议补充一个完整的用户操作示例,展示从输入数据到获取校验结果的完整流程

Highlights

  • 文档结构清晰,包含 frontmatter、何时使用、硬约束、推荐实现要点、Agent 步骤等必要章节
  • 提供了具体的 TypeScript 代码示例,便于开发者理解实现方式
Execution Reliability78/100

Areas to improve

  • 安全约束未显式实现 Reported severity: Minor

    文档提到了禁用远程 $ref 等安全约束,但未在代码示例中显式实现

    Recommendation: 建议在代码示例中显式添加禁用远程引用的配置,如 ajv.addMetaSchema 或 strict 模式设置

Highlights

  • 提供了具体的 TypeScript 实现代码,工具来源明确(ajv)
  • 参数配置合理(allErrors: true),能够一次列出多处问题
  • 覆盖了常见校验场景,如必填字段、手机号格式、枚举值等
Evidence Verifiability (mean of the first four)80/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.