5.1.1 • Published 3 years ago

optimal v5.1.1

Weekly downloads
1,760
License
MIT
Repository
github
Last release
3 years ago

Optimal

Build Status npm version npm deps

Optimal is a system for building and validating any value with typed schemas, and first-class support for defined object structures, like options objects, configuration files, validation fields, and many more. Optimal aims to provide a powerful API, with high performance, the lowest possible filesize, and TypeScript-first support.

// Import schemas to build validators withs
import { array, string, number, optimal } from 'optimal';

// Define and validate values with individual schemas
const maxSizeSchema = number().positive().lte(10000);

maxSizeSchema.validate(1234);

// Or define an explicit shaped blueprint
const schema = optimal({
  name: string().notEmpty(),
  include: array().of(string()),
  exclude: array().of(string()),
  maxSize: maxSizeSchema
});

// Pass a full or partial object to validate
const options = schema.validate({ name: 'Optimal' });

// Which validates, builds, and returns the following object
{
  name: 'Optimal',
  include: [],
  exclude: [],
  maxSize: 10000,
}

Features

  • Zero dependencies, with a tree-shakable API.
  • Powerful inferrence using a TypeScript first design.
  • Runs in both Node.js and the browser.
  • Smallest filesize: 5kB minified and gzipped!
  • Immutable & fluent schema builder pattern.
  • Recursively builds and validates nested structures.
  • Supports common data types.
  • Autofills missing fields with default values.
  • Allows or restricts unknown fields.
  • Mark fields as nullable or required.
  • Handles logical operators AND, OR, and XOR.

Requirements

  • Node v12.17 (server)
  • Edge, Chrome, Firefox, Safari (browser)

Installation

yarn add optimal

Documentation

https://optimallib.dev

5.1.1

3 years ago

5.1.0

3 years ago

5.0.0

3 years ago

5.0.0-alpha.5

3 years ago

5.0.0-alpha.4

3 years ago

5.0.0-alpha.3

3 years ago

5.0.0-alpha.2

3 years ago

5.0.0-alpha.1

3 years ago

4.3.0

3 years ago

4.2.1

3 years ago

4.2.0

4 years ago

4.1.2

4 years ago

4.1.1

4 years ago

4.1.0

4 years ago

4.0.1

4 years ago

4.0.0

4 years ago

4.0.0-2

4 years ago

4.0.0-1

4 years ago

4.0.0-0

4 years ago

3.4.0

4 years ago

3.3.0

4 years ago

3.2.1

5 years ago

3.2.0

5 years ago

3.1.1

5 years ago

3.1.0

5 years ago

3.1.0-0

5 years ago

3.0.0

5 years ago

3.0.0-0

5 years ago

2.2.0-1

5 years ago

2.2.0-0

5 years ago

2.1.1

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

2.0.0-2

5 years ago

2.0.0-1

5 years ago

2.0.0-0

5 years ago

1.2.0

5 years ago

1.1.3

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.20.0

6 years ago

0.19.0

6 years ago

0.18.0

6 years ago

0.17.3

6 years ago

0.17.2

6 years ago

0.17.1

6 years ago

0.17.0

6 years ago

0.16.0

6 years ago

0.15.0

6 years ago

0.14.0

7 years ago

0.13.0

7 years ago

0.12.0

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.9.0

7 years ago

0.8.0

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.1

7 years ago

0.3.0

7 years ago

0.2.0

7 years ago

0.1.0

11 years ago

0.0.3

12 years ago

0.0.2

12 years ago