UNPKG

@respeecher/respeecher-js

Version:

[![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Frespeecher%2Frespeecher-js) [![npm shield](

23 lines (22 loc) 734 B
import { SchemaType } from "../../Schema.mjs"; import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator.mjs"; import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType.mjs"; export const string = createIdentitySchemaCreator(SchemaType.STRING, (value, { breadcrumbsPrefix = [] } = {}) => { if (typeof value === "string") { return { ok: true, value, }; } else { return { ok: false, errors: [ { path: breadcrumbsPrefix, message: getErrorMessageForIncorrectType(value, "string"), }, ], }; } });