How to use the @marblejs/middleware-io.t.boolean 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
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]),
  metaTitle: t.union([t.string, t.null]),
  metaDescription: t.union([t.string, t.null]),
  reactions: t.type({
    types: t.type({
      unicorn: t.type({ count: Positive }),
      heart: t.type({ count: Positive }),
      mark: t.type({ count: Positive }),
    }),
  }),
  lang: t.union([t.literal(ArticleLanguage.FR), t.literal(ArticleLanguage.EN)]),
});

export type ArticlePayload = t.TypeOf;