UNPKG

io-ts-types

Version:

A collection of codecs and combinators for use with io-ts

19 lines (18 loc) 647 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.regexp = void 0; var fromRefinement_1 = require("./fromRefinement"); var isRegExp = function (u) { return Object.prototype.toString.call(u) === '[object RegExp]'; }; /** * @example * import { regexp } from 'io-ts-types/lib/regexp' * import { right } from 'fp-ts/lib/Either' * * const input1 = /\w+/ * const input2 = new RegExp('\\w+') * assert.deepStrictEqual(regexp.decode(input1), right(input1)) * assert.deepStrictEqual(regexp.decode(input2), right(input2)) * * @since 0.4.4 */ exports.regexp = fromRefinement_1.fromRefinement('RegExp', isRegExp);