schema-special-usage.test.js — fastify Source File
Architecture documentation for schema-special-usage.test.js, a javascript file in the fastify codebase.
Entity Profile
Source Code
'use strict'
const { test } = require('node:test')
const Joi = require('joi')
const yup = require('yup')
const AJV = require('ajv')
const S = require('fluent-json-schema')
const Fastify = require('..')
const ajvMergePatch = require('ajv-merge-patch')
const ajvErrors = require('ajv-errors')
const proxyquire = require('proxyquire')
const { waitForCb } = require('./toolkit')
test('Ajv plugins array parameter', (t, testDone) => {
t.plan(3)
const fastify = Fastify({
ajv: {
customOptions: {
allErrors: true
},
plugins: [
[ajvErrors, { singleError: '@@@@' }]
]
}
})
fastify.post('/', {
schema: {
body: {
type: 'object',
properties: {
foo: {
type: 'number',
minimum: 2,
maximum: 10,
multipleOf: 2,
errorMessage: {
type: 'should be number',
minimum: 'should be >= 2',
maximum: 'should be <= 10',
multipleOf: 'should be multipleOf 2'
}
}
}
}
},
handler (req, reply) { reply.send({ ok: 1 }) }
})
fastify.inject({
method: 'POST',
url: '/',
payload: { foo: 99 }
}, (err, res) => {
t.assert.ifError(err)
t.assert.strictEqual(res.statusCode, 400)
t.assert.strictEqual(res.json().message, 'body/foo should be <= 10@@@@should be multipleOf 2')
testDone()
})
})
// ... (1289 more lines)
Source
Frequently Asked Questions
What does schema-special-usage.test.js do?
schema-special-usage.test.js is a source file in the fastify codebase, written in javascript.
Where is schema-special-usage.test.js in the architecture?
schema-special-usage.test.js is located at test/schema-special-usage.test.js (directory: test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free