Skip to content
/ runval Public

A typescript first runtime schema validation library

Notifications You must be signed in to change notification settings

guigzzz/runval

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

runval

A typescript first runtime schema validation library.

This library is currently very unstable. It's probably not wise to use it (unless you want to test!)

Usage

import { boolean, number, object, string, Infer } from '../src';

const schema = object({
    string: string(),
    number: number(),
    nestedObject: object({
        anotherNumber: number(),
        boolean: boolean(),
    }),
});

type SchemaType = Infer<typeof schema>;

const data: any = { ... };

// type guard
if (schema.is(data)) {
    // data is typeof schema
}

// validate
const output = schema.validate(data);
if (output.success) {
    const validated = output.data;
}
else {
    throw output.error;
}

About

A typescript first runtime schema validation library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published