hxb20267147

Phone number validation and formatting tool: uses libphonenumber‑js to validate phone numbers and output E.164 and domestic display formats. To be used when a user requests phone formatting, E.164, or libphonenumber‑related operations.

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

Phone number validation and formatting tool: uses libphonenumber‑js to validate phone numbers and output E.164 and domestic display formats. To be used when a user requests phone formatting, E.164, or libphonenumber‑related operations.

0 Downloads

Introduction source: third_party · user_f1b049da · 1.0.0 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Not specified in the source documentation.
Inputs and outputs
Not specified in the source documentation.
Software, accounts and paid services
Not specified in the source documentation.
Limits and differences
Not specified in the source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: hxb20267147
slug: hxb20267147
displayName: 电话格式化校验
version: 1.0.0
summary: 用 libphonenumber-js 解析手机号,输出 E.164 / 国内格式并校验合法性。
license: MIT
description: 用 libphonenumber-js 校验并格式化电话号码(E.164 与国内显示)。当用户要电话格式化、E.164、libphonenumber 时使用。

电话格式化校验(libphonenumber-js)

灵感:能力工具箱 phone-format(pkg: libphonenumber-js)。

小四原创:默认中国 CN;存库建议 E.164,界面可显示国内格式。与「运营商号段识别」Skill 互补。

何时使用

  • 客户手机录入校验与统一格式
  • 导出通讯录要 E.164
  • 国际号码(可选)解析

硬约束

  1. 使用 libphonenumber-js;默认国家 CN 可配置。
  2. 非法号码返回中文原因;合法给出 e164 + national。
  3. 存库字段与展示字段分开,勿混用带空格的展示串当唯一键。
  4. 实现要点注释标 小四原创。
  5. 格式合法 ≠ 实名/可接通。

推荐实现

import { parsePhoneNumberFromString } from 'libphonenumber-js'

export type PhoneResult =
  | { ok: true; e164: string; national: string; type?: string }
  | { ok: false; reason: string }

// 小四原创:解析并格式化
export function formatPhone(input: string, defaultCountry: 'CN' | string = 'CN'): PhoneResult {
  const raw = String(input || '').trim()
  if (!raw) return { ok: false, reason: '请填写电话' }
  const phone = parsePhoneNumberFromString(raw, defaultCountry as any)
  if (!phone || !phone.isValid()) {
    return { ok: false, reason: '电话号码无效' }
  }
  return {
    ok: true,
    e164: phone.format('E.164'),
    national: phone.formatNational(),
    type: phone.getType(),
  }
}

Agent 步骤

  1. 失焦/提交调用 formatPhone。
  2. 成功写入 mobileE164,界面显示 national。
  3. 自测:13800138000、+86 138 0013 8000、非法短号。

不要做

  • 用简单 ^1\d{10}$ 冒充本 Skill 的完整能力却不说明。
  • 把号码发到不明外网校验服务(默认本地库)。

附加

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 Value78/100

Highlights

  • 提供电话号码校验与格式化功能,使用 libphonenumber-js 库,支持 E.164 和国内格式输出
  • 适用于客户手机录入校验、通讯录导出等实际场景,具有明确的实用价值
Trigger Precision85/100

Highlights

  • description 明确指出使用场景(电话格式化、E.164、libphonenumber),触发词覆盖合理,边界清晰
Structure and Standards75/100

Areas to improve

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

    文档结构清晰,包含 frontmatter、何时使用、硬约束、推荐实现、Agent 步骤等,但缺少端到端的完整用户交互示例。

    Recommendation: 建议补充一个完整的用户交互示例,展示从输入到输出的完整流程。

Highlights

  • 文档结构清晰,包含 frontmatter、何时使用、硬约束、推荐实现、Agent 步骤等
  • 有代码示例和自测用例
Execution Reliability78/100

Areas to improve

  • 错误处理说明不完整 Reported severity: Minor

    推荐实现代码逻辑完整,使用知名库 libphonenumber-js,参数处理合理,覆盖了空输入和无效号码的异常情况,但未明确说明错误处理的具体返回格式是否与 Agent 步骤一致。

    Recommendation: 建议在 Agent 步骤中明确说明错误处理的具体返回格式,确保与推荐实现一致。

Highlights

  • 推荐实现代码逻辑完整,使用知名库 libphonenumber-js,参数处理合理
  • 覆盖了空输入和无效号码的异常情况
Evidence Verifiability (mean of the first four)79/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.

Not specified in the source documentation.

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