yrd20261452

Perform lightweight field validation for email, URL, phone number, ID card, and similar fields using a validator. Intended for cases needing validator.js or field validation such as email/URL checks.

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

Perform lightweight field validation for email, URL, phone number, ID card, and similar fields using a validator. Intended for cases needing validator.js or field validation such as email/URL checks.

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: yrd20261452
slug: yrd20261452
displayName: Validator字段校验
version: 1.0.0
summary: 用 validator.js 快速检查邮箱、URL、身份证等字段合法性。
license: MIT
description: 用 validator 对邮箱、URL、手机、身份证等做轻量字段合法性检查。当用户要 validator.js、字段校验、邮箱URL校验时使用。

Validator.js 字段校验(validator)

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

小四原创:单字段快速合法性检查;复杂对象规则仍交给 Zod/Yup。

何时使用

  • 失焦时快速验邮箱 / URL / 手机形态
  • 导入前对单列做批量 every
  • 不想上完整 Schema,只要工具函数

硬约束

  1. 使用 validator(注意默认导出方式随打包器而异)。
  2. 中文场景:手机用宽松/自定义正则或 isMobilePhone(str, 'zh-CN')。
  3. 身份证:可用库能力或提示对接「身份证校验解析」Skill 做校验位。
  4. 失败返回中文原因,不只返回 false。
  5. 实现要点注释标 小四原创。

推荐实现

import validator from 'validator'

export type FieldResult = { ok: true } | { ok: false; reason: string }

// 小四原创:常用字段快检
export function checkEmail(v: string): FieldResult {
  const s = String(v || '').trim()
  if (!s) return { ok: false, reason: '请填写邮箱' }
  return validator.isEmail(s) ? { ok: true } : { ok: false, reason: '邮箱格式不正确' }
}

export function checkUrl(v: string): FieldResult {
  const s = String(v || '').trim()
  if (!s) return { ok: false, reason: '请填写链接' }
  return validator.isURL(s, { require_protocol: true })
    ? { ok: true }
    : { ok: false, reason: '链接须含 http(s)://' }
}

export function checkMobileCN(v: string): FieldResult {
  const s = String(v || '').trim()
  if (!s) return { ok: false, reason: '请填写手机号' }
  return validator.isMobilePhone(s, 'zh-CN')
    ? { ok: true }
    : { ok: false, reason: '手机号格式不正确' }
}

Agent 步骤

  1. 封装 checkEmail / checkUrl / checkMobileCN。
  2. 表单失焦或提交时调用,写入对应错误文案。
  3. 与 Zod/Yup 并存时:validator 做轻量预检,Schema 做对象级。
  4. 自测:合法/非法/空值三条。

不要做

  • 用 validator 替代完整业务规则引擎。
  • 把「格式合法」当成「号码实名有效」。

附加

Current listing version

1.0.0

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value75/100

Highlights

  • 提供邮箱、URL、手机号等常见字段的轻量合法性校验,适用于表单验证、数据导入等高频场景
  • 明确区分轻量校验与完整 Schema 验证的边界,定位清晰
Trigger Precision85/100

Highlights

  • 触发关键词明确(validator.js、字段校验、邮箱URL校验),覆盖合理,边界清晰
Structure and Standards90/100

Highlights

  • Phase/步骤清晰,有出口条件,含端到端示例,frontmatter完整
Execution Reliability70/100

Areas to improve

  • 未处理 validator 库未安装等运行时异常 Reported severity: Major

    代码示例中直接 import validator,但未说明如何处理库未安装或加载失败的情况

    Recommendation: 建议增加运行时异常处理说明,或提供 fallback 方案

  • 未说明如何集成到项目 Reported severity: Minor

    缺少项目集成说明,如安装命令、构建配置等

    Recommendation: 建议补充 npm install validator 等安装说明及基本集成步骤

Highlights

  • 工具来源明确(validator.js),参数正确,覆盖主要异常(空值、格式错误)
  • 返回中文原因提升用户体验,符合中文场景需求
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.