PHPackages                             uuki/schemable-validator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Validation &amp; Sanitization](/categories/validation)
4. /
5. uuki/schemable-validator

ActivePackage[Validation &amp; Sanitization](/categories/validation)

uuki/schemable-validator
========================

Schema based validation plugin.

0.x-dev(1y ago)012[4 PRs](https://github.com/uuki/schemable-validator/pulls)MITPHPPHP &gt;=7.4CI passing

Since Oct 19Pushed 1w ago1 watchersCompare

[ Source](https://github.com/uuki/schemable-validator)[ Packagist](https://packagist.org/packages/uuki/schemable-validator)[ RSS](/packages/uuki-schemable-validator/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (1)Versions (3)Used By (0)

Schemable Validator
===================

[](#schemable-validator)

[![Packagist](https://camo.githubusercontent.com/5f568ef25beec81aab60e979de5b5c9c3ceef30d0aa478360673c2f6c801f26d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f75756b692f736368656d61626c652d76616c696461746f72)](https://packagist.org/packages/uuki/schemable-validator)[![PHP](https://camo.githubusercontent.com/0f7ab036ce2ede97b0c17c52cc02f6d4608193ef9fbeb193c2e3e3ae7c1b71d5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253345253344372e342d3838393242463f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/uuki/schemable-validator)[![WordPress](https://camo.githubusercontent.com/9cbc2b204aea10cd499f574d7d0d7f46443f044550fd0f102a5dbc36364e493c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f576f726450726573732d253345253344352e392d3231373539423f6c6f676f3d776f72647072657373266c6f676f436f6c6f723d7768697465)](https://wordpress.org/)

A dependency-free PHP form validation library. Define constraints once with a fluent API, validate server-side with zero external packages, and optionally export the same rules as JSON Schema for client-side consumption.

✨ Features
----------

[](#-features)

- **Server-side validation with no dependencies.**The default engine (`NativeAdapter`) requires nothing beyond PHP 7.4. `$_POST` string values are automatically coerced to the declared types via the built-in Coercion Contract.
- **Client-side sync when you need it.**Call `toJson()` to produce a JSON Schema (draft 2020-12) document. Built-in Zod and Valibot adapters convert it into native client schemas.
- **Pluggable drivers.**CAPTCHA verification (reCAPTCHA v3, hCaptcha, Cloudflare Turnstile), file upload validation, image constraint checks, and CSRF protection are injected through driver interfaces.

---

📦 Packages
----------

[](#-packages)

PackageDescription[`uuki/schemable-validator`](https://packagist.org/packages/uuki/schemable-validator)PHP core library (framework-agnostic, zero dependencies)`wp-schemable-validator`WordPress plugin — REST endpoint, helpers, Schema Editor admin UI[`@uuki/schemable-validator-client`](https://www.npmjs.com/package/@uuki/schemable-validator-client)TypeScript client — validates against JSON Schema output---

🚀 Quick start
-------------

[](#-quick-start)

### 1. Define constraints (PHP)

[](#1-define-constraints-php)

```
use SchemableValidator\SV;

$schema = SV::object([
  'name'  => SV::string()->min(1)->max(100),
  'email' => SV::string()->email(),
  'tel'   => SV::string()->pattern('^(0\d{9,10}|0\d{1,4}-\d{1,4}-\d{3,4})$')->optional(),
  'type'  => SV::enum(['general', 'support', 'other']),
  'body'  => SV::string()->min(10),
]);
```

### 2. Server-side validation

[](#2-server-side-validation)

```
$result = $schema->toValidator()->validate($_POST)->getResult();
// { "name": { "value": "...", "is_valid": true, "errors": null }, ... }
```

### 3. Expose as REST endpoint (WordPress)

[](#3-expose-as-rest-endpoint-wordpress)

```
// GET /wp-json/schv/v1/schema/contact -> JSON Schema
schv_register_schema('/schema/contact', $schema);
```

### 4. Client-side validation (TypeScript)

[](#4-client-side-validation-typescript)

```
import { validateObject, isAllValid, extractErrors } from '@uuki/schemable-validator-client'

const schema = await fetch('/wp-json/schv/v1/schema/contact').then(r => r.json())
const result = validateObject(formData, schema)

if (!isAllValid(result)) {
  console.log(extractErrors(result))
}
```

Or with Zod / Valibot adapters:

```
import { toZodSchema } from '@uuki/schemable-validator-client/zod'

const zodSchema = toZodSchema(schema)
const parsed = zodSchema.safeParse(formData)
```

---

⚙️ Architecture
---------------

[](#️-architecture)

```
SV::object([...])           server-side validation (NativeAdapter, dependency-free)
    |
    +- toJson()             -> JSON Schema draft 2020-12
           |
           +- REST endpoint (WordPress)
                  |
                  +- @uuki/schemable-validator-client  -> client-side validation
                     Zod / Valibot / any JS validator

```

The validation engine is swappable. Pass a `RespectAdapter` or `OpisAdapter` in the config to use a different backend; the public API and the `{value, is_valid, errors}` result shape stay the same.

Constraints that cannot be expressed in JSON Schema (file uploads, custom rules) are recorded in `x-unmapped-fields` and handled server-side automatically.

---

🔧 Installation
--------------

[](#-installation)

```
# PHP core
composer require uuki/schemable-validator

# WordPress plugin
cd packages/wp-schemable-validator && composer install --no-dev

# TypeScript client
npm install @uuki/schemable-validator-client
```

See [Installation](https://uuki.github.io/schemable-validator/installation) for full setup.

---

📖 Documentation
---------------

[](#-documentation)

Full documentation: [uuki.github.io/schemable-validator](https://uuki.github.io/schemable-validator/)

[Overview](https://uuki.github.io/schemable-validator/overview)Features, architecture[Installation](https://uuki.github.io/schemable-validator/installation)Requirements, package structure[SchemaBuilder](https://uuki.github.io/schemable-validator/schema-builder)Fluent API, JSON Schema output, `mergeJsonSchema()`[Feature Guide](https://uuki.github.io/schemable-validator/feature-guide)Validator, file validation, CAPTCHA, CSRF[Backend Adapters](https://uuki.github.io/schemable-validator/backend-adapters)Swapping the validation engine, custom adapters[Custom Validation](https://uuki.github.io/schemable-validator/custom-validation)`SV::custom()`, escape hatches, `x-unmapped-fields`[MessageDict](https://uuki.github.io/schemable-validator/message-dict)Localisation, custom error messages---

🔗 Dependencies
--------------

[](#-dependencies)

The PHP core requires only PHP &gt;= 7.4 and [`symfony/polyfill-php80`](https://packagist.org/packages/symfony/polyfill-php80). No validation engine is bundled by default.

Optional engine packages are only loaded when explicitly installed:

- [respect/validation](https://packagist.org/packages/respect/validation) ^2.2 — enables `RespectAdapter` and the Respect driver (`RespectRules`, `postalCode`, `creditCard`, `iban`)
- [opis/json-schema](https://packagist.org/packages/opis/json-schema) ^2.6 — enables `OpisAdapter` (strict JSON Schema semantics, no coercion)

---

📄 License
---------

[](#-license)

This project is open-sourced software licensed under the [MIT License](LICENSE).

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance70

Regular maintenance activity

Popularity5

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity26

Early-stage or recently created project

 Bus Factor1

Top contributor holds 86.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

620d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3760515?v=4)[Yuichi Aoki](/maintainers/uuki)[@uuki](https://github.com/uuki)

---

Top Contributors

[![uuki](https://avatars.githubusercontent.com/u/3760515?v=4)](https://github.com/uuki "uuki (142 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (12 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (11 commits)")

---

Tags

json-schemaphprespect-validationtypescriptvalidationwordpress

### Embed Badge

![Health badge](/badges/uuki-schemable-validator/health.svg)

```
[![Health](https://phpackages.com/badges/uuki-schemable-validator/health.svg)](https://phpackages.com/packages/uuki-schemable-validator)
```

###  Alternatives

[awurth/slim-validation

A wrapper around the respect/validation PHP validation library for easier error handling and display

65399.7k9](/packages/awurth-slim-validation)[progsmile/request-validator

Simple PHP Request Validator

37114.5k1](/packages/progsmile-request-validator)[resultsystems/validation

Inspired 'KennedyTedesco Validation' - The power of 'Respect Validation' on Laravel.

2832.8k4](/packages/resultsystems-validation)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
