Logo Hor Resolver Validator

Hor Resolver Validator

Tổ chức
openreachtech
hor-resolver-validator

Implement input-validation classes for GraphQL resolvers under app/validator/forResolver/<endpoint>/{queries,mutations}/, extending BaseInputValidator and delegating value checks to @openreachtech/mentsu-value-inspector. Use this skill whenever the user asks to validate a resolver's input — presence, number, integer, pagination, enum/keyword checks — via a `*InputValidator` class whose failing predicate raises the matching InvalidXxx error.

Tổng quan

Nhà phát hànhopenreachtech
Kho mãhora-skills-ort-renchan
Tên kỹ nănghor-resolver-validator
Sao
32
Bản fork
0
Tệp đi kèm
2
Giấy phépApache-2.0
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI là Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • 2 tệp đi kèm

    Các tập lệnh, mẫu và tài liệu tham khảo mà mô hình có thể đọc khi làm việc. Các tệp chỉ cho phép đọc và không bao giờ được thực thi.

  • Mã nguồn mở

    Được openreachtech công bố trên GitHub. Hãy đọc nội dung nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Hor Resolver Validator trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL thư mục kỹ năng bên dưới và xác nhận.
    https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-resolver-validator
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/openreachtech/hora-skills-ort-renchan.git /tmp/hora-skills-ort-renchan
mkdir -p .claude/skills
cp -r /tmp/hora-skills-ort-renchan/kit/skills/hor-resolver-validator .claude/skills/hor-resolver-validator
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Hor Resolver Validator trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự tải Hor Resolver Validator ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên Hor Resolver Validator không bị giới hạn ở mô hình mà kỹ năng này được viết cho. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên kỹ năng chưa dùng không tốn chi phí.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Resolver Validator

A skill for writing the *InputValidator classes that GraphQL resolvers use to reject bad input. A validator extends BaseInputValidator and declares a list of [predicate, ErrorConstructor] entries; the base runs them and, for the first predicate that returns false, raises that entry's error. Per-value checks (presence / number / integer / positive-integer …) are delegated to @openreachtech/mentsu-value-inspector, imported directly (it is a published module — use it from the package, not a local wrapper).

The support classes (BaseInputValidator, NormalPaginationInputValidator) ship with renchan-boilerplate under app/validator/forResolver/; the inspectors come from the @openreachtech/mentsu-value-inspector module.

Grand principle: declare [predicate, error] entries, let the base run them

A validator is a BaseInputValidator subclass whose only required override is generateValidationEntries() — it returns Array<[() => boolean, RenchanGraphqlErrorCtor]>. Each entry pairs a predicate (returns true when that rule passes) with the error constructor to raise when it fails. The base holds this.input and this.errorHash, iterates the entries, and throws the error of the first failing predicate.

  • Predicates are small isValidX() methods that read this.input and return a boolean. They use the inspector classes and/or composed sub-validators — they never throw.
  • Errors come from this.errorHash (the resolver's error hash, injected into the validator), so each InvalidXxx maps to the resolver's errorCodeHash code.
  • Reuse shared validators (e.g. pagination) by composing them inside entries, not by re-implementing limit/offset/sort.
js
import {
  IntegerValueInspector,
} from '@openreachtech/mentsu-value-inspector'

import BaseInputValidator from '../../BaseInputValidator.js'
import PaginationInputValidator from '../../NormalPaginationInputValidator.js'

const VALID_SORT_COLUMNS = [
  'labelName',
  'fieldPath',
]

/**
 * Class for validating input of the emailInsertableVariables query
 *
 * @extends {BaseInputValidator<ErrorHash, EmailInsertableVariablesInput>}
 */
export default class EmailInsertableVariablesInputValidator extends BaseInputValidator {
  /**
   * Generate validation entries
   *
   * @override
   * @returns {Array<[() => boolean, RenchanGraphqlErrorCtor]>}
   */
  generateValidationEntries () {
    const paginationInputValidator = this.createPaginationInputValidator()

    return [
      [
        () => paginationInputValidator.isValidLimit(),
        this.errorHash.InvalidPaginationLimit,
      ],
      [
        () => paginationInputValidator.isValidOffset(),
        this.errorHash.InvalidPaginationOffset,
      ],
      [
        () => paginationInputValidator.isValidSort(),
        this.errorHash.InvalidPaginationSort,
      ],
      [
        () => this.isValidKeyword(),
        this.errorHash.InvalidKeyword,
      ],
      [
        () => this.isValidOriginObjectCategoryId(),
        this.errorHash.InvalidOriginObjectCategoryId,
      ],
    ]
  }

  // ... isValidX() predicates + create*Inspector helpers (see validator-pattern.md) ...
}

Directory & naming

  • Validators: app/validator/forResolver/<endpoint>/<operation-kind>/<Operation>InputValidator.js
    • <endpoint> tracks the GraphQL endpoint the resolver belongs to (user, customer, admin, …) — it changes per endpoint.
    • <operation-kind> is queries or mutations.
    • e.g. app/validator/forResolver/user/queries/EmailInsertableVariablesInputValidator.js, app/validator/forResolver/user/mutations/CreateFooInputValidator.js.
  • Shared under app/validator/forResolver/: BaseInputValidator.js and reusable validators such as NormalPaginationInputValidator.js (default-exported, commonly imported as PaginationInputValidator).
  • Inspectors: imported directly from @openreachtech/mentsu-value-inspector (ValueInspector / NumberValueInspector / IntegerValueInspector) (inspector-api.md).
  • Class name = <Operation>InputValidator (PascalCase, matching the resolver's schema).

Predicates & the inspector

Each rule is an isValidX() method. For value-shape checks, build an inspector via a small create*ValueInspector({ value }) helper and call its methods:

js
isValidOriginObjectCategoryId () {
  const inspector = this.createIntegerValueInspector({
    value: this.input.originObjectCategoryId,
  })

  // the module has no isPositiveInteger — compose it (string-tolerant *Like)
  return inspector.isIntegerLike()
    && inspector.isPositiveNumberLike()
}

createIntegerValueInspector ({
  value,
}) {
  return IntegerValueInspector.create({
    value,
  })
}
  • Optional field idiom: return true early when the field is absent, then check the shape — e.g. if (!keyword) { return true } before return typeof keyword === 'string'.
  • The *Like methods accept numeric strings, which is what you want at the GraphQL boundary; there is no isPositiveInteger, so compose it (inspector-api.md).

Error hash & resolver wiring

The resolver declares the codes and passes its errorHash into the validator:

js
/** @override */
static get errorCodeHash () {
  return {
    ...super.errorCodeHash,

    InvalidKeyword: '400.C001.001',
    InvalidOriginObjectCategoryId: '400.C001.002',
    InvalidPaginationLimit: '400.C001.003',
    InvalidPaginationOffset: '400.C001.004',
    InvalidPaginationSort: '400.C001.005',
  }
}

/** @override */
async resolve ({
  variables: {
    input,
  },
  context,
}) {
  EmailInsertableVariablesInputValidator
    .create({
      input,
      errorHash: this.errorHash,
    })
    .validate()

  // ... input is now trusted ...
}

create({ input, errorHash }) and validate() come from BaseInputValidator. A resolver that decides itself when to throw calls validateInput(), which returns the error or null.

Testing

Predicates are pure booleans, so unit-test them (and generateValidationEntries) with the hoc-jest skill: feed inputs, assert isValidX() results and that invalid input raises the expected InvalidXxx.

Detail files

  • inspector-api.md — the @openreachtech/mentsu-value-inspector API (strict vs *Like, presence / number / integer, composing positive-integer, cheat sheet)
  • validator-pattern.md — the full validator template (generateValidationEntries, predicates, inspector helpers, composed pagination, typedefs), the BaseInputValidator contract, resolver wiring, and testing

Tệp đi kèm

Mô hình đọc các tệp này khi cần trong lúc kỹ năng được tải. Các tệp được cung cấp ở dạng có thể đọc và không bao giờ được thực thi.

Câu hỏi thường gặp

Kỹ năng AI Hor Resolver Validator làm được gì?

Implement input-validation classes for GraphQL resolvers under app/validator/forResolver/<endpoint>/{queries,mutations}/, extending BaseInputValidator and delegating value checks to @openreachtech/mentsu-value-inspector. Use this skill whenever the user asks to validate a resolver's input — presence, number, integer, pagination, enum/keyword checks — via a `*InputValidator` class whose failing predicate raises the matching InvalidXxx error.

Vì sao nên dùng Hor Resolver Validator trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Hor Resolver Validator là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Hor Resolver Validator trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/openreachtech/hora-skills-ort-renchan/tree/main/kit/skills/hor-resolver-validator. TypingMind đọc tệp SKILL.md, đóng gói các tệp đi kèm và cài đặt thành một kỹ năng mà bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Hor Resolver Validator?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Bạn có thể dùng Hor Resolver Validator với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Hor Resolver Validator với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Hor Resolver Validator có miễn phí không?

Có. Kỹ năng này được openreachtech phát hành trên GitHub theo giấy phép Apache-2.0. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp cho mô hình các công cụ mới để gọi — mã được chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và tiêu chí của đầu ra tốt. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇