pipe (位)

Schemas may become hard to read as nesting grows, which may be solved by function composition in the form of the provided pipe utility function.

import { nonEmpty, nullable, pipe, string } from '@typeofweb/schema';
pipe(string, nullable, nonEmpty);
// is equivalent to
nonEmpty(nullable(string()));

is an alias for pipe:

import { nonEmpty, minLength, nil,, object, string } from '@typeofweb/schema';
const blogSchema = object({
title: (string, minLength(10)),
description: (string, nil),
href: (string, nil, nonEmpty),
rssUrl: (string, nil, nonEmpty),
})();
Last updated on by Micha艂 Miszczyszyn