How to use the @marblejs/middleware-io.t.brand function in @marblejs/middleware-io

To help you get started, we’ve selected a few @marblejs/middleware-io examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github edbzn / reactive-blog / packages / server / src / api / article / helpers / article-body.validator.ts View on Github external
import { requestValidator$, t } from '@marblejs/middleware-io';

import { ArticleLanguage } from '../model/article-language';

interface PositiveBrand {
  readonly Positive: unique symbol;
}

const Positive = t.brand(
  t.number,
  (n): n is t.Branded => n >= 0,
  'Positive'
);

type Positive = t.TypeOf;

export const articleSchema = t.type({
  title: t.string,
  markdown: t.string,
  html: t.string,
  tags: t.array(t.string),
  slug: t.string,
  published: t.boolean,
  publishedAt: t.union([t.string, t.null]),
  posterUrl: t.union([t.string, t.null]),