Elegant validation library for type-safe input data (for TypeScript and Flow)
MIT License
Bot releases are hidden (Show)
email
validator based on the almost perfect email regex
url
validator for validating HTTPS URLs (most common use case)anyUrl
validator for validating any URL schemePublished by nvie almost 7 years ago
This is the first stable release, and marks a point where I'm comfortable with the public API and I expect no signature changes in it.
Breaking change New API: simplified names, split up decoders from guards.
What used to be called "decoders" in 0.0.x ("things that either return
a value or throw a runtime error") are now called "guards" in 0.1.0.
The meaning of the term "decoders" is now changed to a thing that either is
an "Ok" value or an "Err" value.
To convert to the new API, do this:
// Old way
import { decodeNumber, decodeObject, decodeString } from 'decoders';
const decoder = decodeObject({
name: decodeString(),
age: decodeNumber(),
});
// -------------------------------------------------------------------
// New way
import { guard, number, object, string } from 'decoders';
const guard = guard(object({
name: string,
age: number,
}));