fst20266835

Declare validation rules for customer/lead objects with yup, adapted for Element Plus complex nested forms; to be used when yup validation, object validation, or Element Plus form rules are required.

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 "fst20266835" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-81655608e44191cc422707bcdd3fe0916f4e5f9712e48887b3ad885bb8070ca4. Verify the upstream source and version against https://skillhub.cn/skills/user_f1b049da/fst20266835 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

Declare validation rules for customer/lead objects with yup, adapted for Element Plus complex nested forms; to be used when yup validation, object validation, or Element Plus form rules are required.

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: fst20266835
slug: fst20266835
displayName: Yup对象校验
version: 1.0.0
summary: 用 Yup 做声明式对象校验,适配 Element Plus 嵌套客户表单。
license: MIT
description: 用 yup 声明客户/线索对象校验规则,适配 Element Plus 复杂嵌套表单。当用户要 Yup 校验、对象校验、Element Plus 表单规则时使用。

Yup 对象校验(yup)

灵感:能力工具箱 yup(pkg: yup)。

小四原创:声明式 schema + validate;错误可转成 Element Plus rules 或字段 map。与 Zod 二选一作主方案。

何时使用

  • Element Plus 复杂嵌套表单(联系人数组、地址对象)
  • 习惯 Yup / Formik 风格声明式校验
  • 需要异步校验扩展点(如重名检查,慎用)

硬约束

  1. 使用 yup;优先 validate(data, { abortEarly: false }) 收齐错误。
  2. 文案中文;label 用业务名。
  3. 与 Zod 同项目勿双栈绑同一表单。
  4. 异步校验须防抖且失败可降级。
  5. 实现要点注释标 小四原创。

推荐实现

import * as yup from 'yup'

// 小四原创:客户对象 Schema
export const customerYup = yup.object({
  company: yup.string().trim().required('请填写公司名').min(2, '公司名过短'),
  contact: yup.string().trim().required('请填写联系人'),
  mobile: yup
    .string()
    .trim()
    .required('请填写手机号')
    .matches(/^1\d{10}$/, '手机号须为11位'),
  address: yup.object({
    city: yup.string().optional(),
    detail: yup.string().max(200, '地址过长').optional(),
  }),
})

export async function validateCustomer(data: unknown) {
  try {
    const value = await customerYup.validate(data, { abortEarly: false })
    return { ok: true as const, value }
  } catch (e) {
    if (e instanceof yup.ValidationError) {
      const fieldErrors: Record<string, string> = {}
      for (const err of e.inner.length ? e.inner : [e]) {
        const key = err.path || '_form'
        if (!fieldErrors[key]) fieldErrors[key] = err.message
      }
      return { ok: false as const, fieldErrors }
    }
    throw e
  }
}

Agent 步骤

  1. 写 Yup schema;嵌套用 yup.object / yup.array。
  2. 提交时 validateCustomer;把 fieldErrors 填入 EP 表单项。
  3. 可选:yup.reach 做单字段失焦校验。
  4. 自测:必填、手机、嵌套地址三条。

不要做

  • 在 schema 里写重业务逻辑(审批流等)。
  • 默认开启会拖垮输入的远程校验。

附加

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value82/100

Highlights

  • 提供 Yup 声明式对象校验能力,适配 Element Plus 复杂嵌套表单,解决前端开发中的实际痛点
  • 面向明确的前端开发者群体,具有较高的实用价值和通用性
Trigger Precision88/100

Highlights

  • 触发词清晰明确,覆盖 Yup 校验、对象校验、Element Plus 表单规则等核心场景
  • 边界定义合理,不易与其他 Skill 产生重叠
Structure and Standards75/100

Areas to improve

  • 缺少端到端完整示例 Reported severity: Minor

    文档提供了代码片段和步骤说明,但缺少一个完整的端到端使用示例(如完整表单集成流程)

    Recommendation: 建议补充一个完整的 Element Plus 表单集成示例,展示从 schema 定义到错误处理的完整流程

  • 文档内容略长 Reported severity: Minor

    文档总行数较多,可能影响用户快速获取关键信息

    Recommendation: 建议适当精简内容,或将部分内容移至附加文档中

Highlights

  • 文档结构完整,包含何时使用、硬约束、推荐实现、Agent 步骤等必要章节
  • 提供了清晰的实现要点和自测建议
Execution Reliability78/100

Areas to improve

  • Element Plus rules 转换实现不明确 Reported severity: Minor

    文档提到错误可转成 Element Plus rules,但未提供具体实现方式

    Recommendation: 建议补充 fieldErrors 到 Element Plus rules 的具体转换示例

Highlights

  • 工具来源明确(yup),参数使用正确,覆盖了主要异常处理
  • 提供了降级机制说明,增强了执行可靠性
Evidence Verifiability (mean of the first four)81/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.