How to use @commercial/joi - 2 common examples

To help you get started, we’ve selected a few @commercial/joi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hapijs / hapi / test / security.js View on Github external
it('prevents xss in path validation response message', (done) => {

        const server = new Hapi.Server();
        server.connection();
        server.state('encoded', { encoding: 'iron' });

        server.route({
            method: 'GET', path: '/fail/{name}', handler: function (request, reply) {

                return reply('Success');
            },
            config: {
                validate: { params: { name: Joi.number() } }
            }
        });

        server.inject({
            method: 'GET',
            url: '/fail/
github hapijs / hapi / test / security.js View on Github external
it('prevents xss in query validation response message', (done) => {

        const server = new Hapi.Server();
        server.connection();
        server.route({
            method: 'GET', path: '/fail/query', handler: function (request, reply) {

                return reply('Success');
            },
            config: {
                validate: { query: { name: Joi.string() } }
            }
        });

        server.inject({
            method: 'GET',
            url: '/fail/query?=value'
        },
        (res) => {

            expect(res.result.message).to.not.contain('

@commercial/joi

Object schema validation

SEE LICENSE IN LICENSE.md
Latest version published 6 years ago

Package Health Score

59 / 100
Full package analysis

Popular @commercial/joi functions