Skip to main content

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, minStringLength, nil,, object, string } from '@typeofweb/schema';

const blogSchema = object({
title: (string, minStringLength(10)),
description: (string, nil),
href: (string, nil, nonEmpty),
rssUrl: (string, nil, nonEmpty),
})();