Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(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;
export const articleValidator$ = requestValidator$({ body: articleSchema });export const createQuery = (opts: CollectionQueryValidatorOpts) =>
t.partial({
sortBy: t.union(opts.sortBy.map(s => t.literal(s)) as any),
sortDir: t.union([
t.refinement(t.union([t.string, t.number]), n => Number(n) === SortDir.ASC, 'SortDir.ASC'),
t.refinement(t.union([t.string, t.number]), n => Number(n) === SortDir.DESC, 'SortDir.DESC'),
]),
limit: t.refinement(t.union([t.string, t.number]), n => Number(n) >= 0, 'number.0+'),
page: t.refinement(t.union([t.string, t.number]), n => Number(n) >= 1, 'number.1+'),
});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;
export const articleValidator$ = requestValidator$({ body: articleSchema });