mirror of
https://gitlab.com/soapbox-pub/ditto.git
synced 2025-12-06 11:29:46 +00:00
11 lines
425 B
TypeScript
11 lines
425 B
TypeScript
import ISO6391 from 'iso-639-1';
|
|
import { z } from 'zod';
|
|
|
|
/** https://github.com/colinhacks/zod/issues/1630#issuecomment-1365983831 */
|
|
export const booleanParamSchema = z.enum(['true', 'false']).transform((value) => value === 'true');
|
|
|
|
/** Value is a ISO-639-1 language code. */
|
|
export const languageSchema = z.string().refine(
|
|
(val) => ISO6391.validate(val),
|
|
{ message: 'Not a valid language in ISO-639-1 format' },
|
|
);
|