/
erioxis
/
web-nodejs
Обзор
Документация
Войти
/
erioxis
/
web-nodejs
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
master
backend/node_modules/fast-json-stringify/test/regex.test.js
32 строки
661 B
erioxis
lab11fix
15 дек 2025, 23:21
15 дек 2025, 23:21
70dc7ba
Код
Авторство
О чём код?
'use strict' const { test } = require('node:test') const validator = require('is-my-json-valid') const build = require('..') test('object with RexExp', (t) => { t.plan(3) const schema = { title: 'object with RegExp', type: 'object', properties: { reg: { type: 'string' } } } const obj = { reg: /"([^"]|\\")*"/ } const stringify = build(schema) const validate = validator(schema) const output = stringify(obj) t.assert.doesNotThrow(() => JSON.parse(output)) t.assert.equal(obj.reg.source, new RegExp(JSON.parse(output).reg).source) t.assert.ok(validate(JSON.parse(output)), 'valid schema') })