@robinpath/schema
v0.1.1
Published
Lightweight schema validation: validate data against type schemas with constraints
Downloads
156
Readme
@robinpath/schema
Lightweight schema validation: validate data against type schemas with constraints
Why use this module?
The schema module lets you:
- Validate data against a schema
- Check if data matches schema (boolean)
- Create a string schema
- Create a number schema
- Create a boolean schema
All functions are callable directly from RobinPath scripts with a simple, consistent API.
Installation
npm install @robinpath/schemaQuick Start
No credentials needed — start using it right away:
schema.isValid $data $schemaAvailable Functions
| Function | Description |
|----------|-------------|
| schema.validate | Validate data against a schema |
| schema.isValid | Check if data matches schema (boolean) |
| schema.string | Create a string schema |
| schema.number | Create a number schema |
| schema.boolean | Create a boolean schema |
| schema.array | Create an array schema |
| schema.object | Create an object schema |
| schema.nullable | Make a schema also accept null |
| schema.oneOf | Create a schema matching one of several schemas |
| schema.getErrors | Validate and return only the errors array |
Examples
Check if data matches schema (boolean)
schema.isValid $data $schemaCreate a string schema
schema.string {"minLength": 1}Create a number schema
schema.number {"min": 0, "max": 100}Integration with RobinPath
import { RobinPath } from "@wiredwp/robinpath";
import Module from "@robinpath/schema";
const rp = new RobinPath();
rp.registerModule(Module.name, Module.functions);
rp.registerModuleMeta(Module.name, Module.functionMetadata);
const result = await rp.executeScript(`
schema.isValid $data $schema
`);Full API Reference
See MODULE.md for complete documentation including all parameters, return types, error handling, and advanced examples.
Related Modules
@robinpath/json— JSON module for complementary functionality
License
MIT
