README.md

@cutticat/validation

Structure validation library.

Table of Contents

Overview

The library provides object structure validation against a reference and file tree structure validation. Uses types from @cutticat/types and paths from @cutticat/properties.

Installation

pnpm i @cutticat/validation

Quick Start

Object validation (neutral — works everywhere)

import {
  validateObjectStructureByReference,
  isObjectStructureMatchesReference,
} from "@cutticat/validation"

// Structure check
validateObjectStructureByReference(
  { name: "John", age: 30 },
  { name: "Иван", age: 25 }
)
// OK — structure matches

// Boolean check
isObjectStructureMatchesReference({ name: "John" }, { name: "Иван" }) // true
isObjectStructureMatchesReference({ name: "John" }, { age: 30 })      // false

File tree validation (Node.js)

import {
  validateFileTreeByReference,
  isFileTreeMatchesReference,
} from "@cutticat/validation/node"

// Directory structure check
await validateFileTreeByReference("./dist", "./src")

// Boolean check
const valid = await isFileTreeMatchesReference("./dist", "./src", { strictFileCountCheck: true })

API

Objects (neutral)

  • validateObjectStructureByReference(target, reference, options?) — validates object structure against a reference, throws on mismatch
  • isObjectStructureMatchesReference(target, reference, options?) — returns true/false
  • ObjectStructureValidationByReferenceOptions — options: path, strict, strictNullChecks, strictArrayLengthCheck, strictObjectKeyCountChecks, validate

Structure / FS (Node.js, @cutticat/validation/node)

  • validateFileTreeByReference(targetDirPath, referenceDirPath, options?) — validates a file tree, throws when a file is missing
  • isFileTreeMatchesReference(targetDirPath, referenceDirPath, options?) — returns true/false
  • FileTreeValidationByReferenceOptions — options: strict, strictFileCountCheck, validate

Documentation

Detailed documentation:

Full API documentation is available in JSDoc comments. Use IDE autocomplete to browse it.

Requirements

  • Node.js >= 22.0.0
  • pnpm >= 10.17.0
  • TypeScript >= 5.9.0
Описание
A library with various utilities for object validation, file system, and more.
Конвейеры
6 успешных
4 с ошибкой
Разработчики