UNPKG

@prismicio/types-internal

Version:
16 lines (15 loc) 686 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const tslib_1 = require("tslib"); const Either_1 = require("fp-ts/Either"); const function_1 = require("fp-ts/function"); const io_ts_1 = require("io-ts"); const StringOrNull_1 = (0, tslib_1.__importDefault)(require("./StringOrNull")); exports.default = new io_ts_1.Type("nonEmptyStringOrNull", (u) => typeof u === "string" || u === null, (u, c) => (0, function_1.pipe)(StringOrNull_1.default.validate(u, c), (0, Either_1.chain)((s) => { if (typeof s === "string" && s.length > 0) { return (0, io_ts_1.success)(s); } else { return (0, io_ts_1.success)(null); } })), (s) => s);