How to use the joi-browser.string function in joi-browser

To help you get started, we’ve selected a few joi-browser 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 hundredrabbits / Pilot / desktop / sources / scripts / old / udp / routes / synths.js View on Github external
const _ = require('lodash')
const Joi = require('joi-browser')
const shortie = require('getshortie')
const base16 = require('../../lib/base16')

module.exports = {
  path: /S(\d)([A-Za-z\#]+\#)([0-9a-fA-F]+)/,
  params: {
    channel: Joi.string().required().description('The channel to operate on'),
    path: Joi.string().required().description('short path notation. # char is path char, and must end in #'),
    value: Joi.string().description('base16 value to set the effect to')
  },
  handler: (pilot, params) => {
    console.log('synth change', params)
    let channel = pilot.getChannel(params.channel)
    if (!channel) return
    let describe = channel.describe()
    let path = params.path.split('#')
    path.pop() // ditch the last #
    let _path = path.join('.')
    let synthSchema = shortie.get(describe, _path)
    if (!synthSchema) return

    let schema = Joi.describe(synthSchema)
    let value = base16.fromSchemaType(schema, params.value)
    let fullPath = shortie.path(describe, _path)
    channel.set(fullPath, value)
github hundredrabbits / Pilot / desktop / sources / scripts / udp / routes / effectsByPath.js View on Github external
const _ = require('lodash')
const Joi = require('joi-browser')
const shortie = require('getshortie')
const base16 = require('../../lib/base16')

module.exports = {
  path: /E(\d)(\d)([A-Za-z\#]+\#)([0-9a-fA-F]+)/,
  params: {
    channel: Joi.string().required().description('The channel to operate on'),
    effect: Joi.number().required().description('the effect index in the effects array'),
    effectPath: Joi.string().required().description('short path notation. # char is path char, and must end in #'),
    value: Joi.string().description('base16 value to set the effect to')
  },
  handler: (pilot, params) => {
    let channel = pilot.getChannel(params.channel)
    if (!channel) return
    let effect = channel.getEffect(params.effect)
    if (!effect) return
    let describe = effect.describe()
    let path = params.effectPath.split('#')
    path.pop() // ditch the last #
    let _path = path.join('.')
    let effectSchema = shortie.get(describe, _path)
    if (!effectSchema) return
github hundredrabbits / Pilot / desktop / sources / scripts / udp / routes / effectsByPath.js View on Github external
const _ = require('lodash')
const Joi = require('joi-browser')
const shortie = require('getshortie')
const base16 = require('../../lib/base16')

module.exports = {
  path: /E(\d)(\d)([A-Za-z\#]+\#)([0-9a-fA-F]+)/,
  params: {
    channel: Joi.string().required().description('The channel to operate on'),
    effect: Joi.number().required().description('the effect index in the effects array'),
    effectPath: Joi.string().required().description('short path notation. # char is path char, and must end in #'),
    value: Joi.string().description('base16 value to set the effect to')
  },
  handler: (pilot, params) => {
    let channel = pilot.getChannel(params.channel)
    if (!channel) return
    let effect = channel.getEffect(params.effect)
    if (!effect) return
    let describe = effect.describe()
    let path = params.effectPath.split('#')
    path.pop() // ditch the last #
    let _path = path.join('.')
    let effectSchema = shortie.get(describe, _path)
    if (!effectSchema) return

    let schema = Joi.describe(effectSchema)
    let value = base16.fromSchemaType(schema, params.value)
    let fullPath = shortie.path(describe, _path)
github mattapperson / react-joi-forms / tests / form.spec.js View on Github external
it("Should create a form object with one input", () => {
        var joyStuff = [Joi.string().label("First Name")];
        var FormComponent = TestUtils.renderIntoDocument(
            <form>
        );
        var inputs = TestUtils.scryRenderedDOMComponentsWithTag(
            FormComponent,
            "input"
        );
        console.log(FormComponent);
        expect(inputs).to.exist;
        expect(inputs.length).to.equal(1);
        expect(inputs[0].type).to.equal("text");
    });
</form>
github mattapperson / react-joi-forms / tests / section.spec.js View on Github external
it("Should use camel cased label for name when no name provided", done =&gt; {
        var joyStuff = [Joi.string().label("First Name")];
        var FormComponent = TestUtils.renderIntoDocument(
            <form> {
                    expect(values).to.exist;
                    expect(values.firstName).to.exist;

                    done();
                }}
            /&gt;
        );
        var form = TestUtils.findRenderedDOMComponentWithTag(
            FormComponent,
            "form"
        );
        var input = TestUtils.scryRenderedDOMComponentsWithTag(</form>
github hundredrabbits / Pilot / desktop / sources / scripts / old / udp / routes / send.js View on Github external
const _ = require('lodash')
const Joi = require('joi-browser')
const shortie = require('getshortie')
const keysDeep = require('lodash-flatkeystree')
const get = require('getshortie')
_.mixin(keysDeep)
const base16 = require('../../lib/base16')

module.exports = {
  path: /C(\d)SEND(\d)([0-9a-fA-F])/,
  params: {
    channel: Joi.string().required().description('The channel to operate on'),
    send: Joi.number().required().description('the send index in the send array'),
    value: Joi.string().description('base16 value to set the effect to')
  },
  handler: (pilot, params) => {
    console.log('da send')
    let channel = pilot.getChannel(params.channel)
    if (!channel) return
    console.log('got channel')
    let send = channel.getSend(params.send)
    if (!send) return
    console.log('got send')
    if (send.target === 'effects') {
      console.log('target ef')
      let effect = channel.getEffect(send.which)
      if (!effect) return
      console.log('got effect')
github hundredrabbits / Pilot / desktop / sources / scripts / old / udp / routes / send.js View on Github external
const _ = require('lodash')
const Joi = require('joi-browser')
const shortie = require('getshortie')
const keysDeep = require('lodash-flatkeystree')
const get = require('getshortie')
_.mixin(keysDeep)
const base16 = require('../../lib/base16')

module.exports = {
  path: /C(\d)SEND(\d)([0-9a-fA-F])/,
  params: {
    channel: Joi.string().required().description('The channel to operate on'),
    send: Joi.number().required().description('the send index in the send array'),
    value: Joi.string().description('base16 value to set the effect to')
  },
  handler: (pilot, params) => {
    console.log('da send')
    let channel = pilot.getChannel(params.channel)
    if (!channel) return
    console.log('got channel')
    let send = channel.getSend(params.send)
    if (!send) return
    console.log('got send')
    if (send.target === 'effects') {
      console.log('target ef')
      let effect = channel.getEffect(send.which)
      if (!effect) return
      console.log('got effect')
      let describe = effect.describe()
github mattapperson / react-joi-forms / src / Input.spec.js View on Github external
test("Should work with no frills", () =&gt; {
        var component = shallow(<input type="password">, {
            context: {
                joiFormGlobal: {
                    components: {
                        password: () =&gt; {
                            return <span>;
                        }
                    }
                },
                joiForm: {
                    schema: {
                        name: Joi.string()
                    },
                    values: {},
                    errors: {},
                    onChange: () =&gt; {},
                    onEvent: () =&gt; {}
                }
            }
        });
        const getFieldParams = component.instance().__getFieldParams;
        const fieldParams = getFieldParams(
            component.context().joiForm.values.name,
            component.instance().props,
            component.context().joiForm.schema.name
        );

        expect(fieldParams.name).toEqual("name");</span>
github hundredrabbits / Pilot / desktop / sources / scripts / lib / types / core / TimeSchema.js View on Github external
const Joi = require('joi-browser')

module.exports = Joi.alternatives().try(
  Joi.number().description('seconds format'),
  Joi.string().regex(/\d[ntb]/).description('BPM time signature')
).label('Time')
github hundredrabbits / Pilot / desktop / sources / scripts / old / udp / routes / mute.js View on Github external
const Joi = require('joi-browser')

module.exports = {
  path: /C(\d)(mute|MUTE)([0-1])/,
  params: {
    channel: Joi.string().required().description('The channel to play on'),
    operation: Joi.string().required().description('what operation to perform on the channel'),
    value: Joi.string().description('1 mutes, 0 unmutes')
  },
  handler: (pilot, params) => {
    let channel = pilot.getChannel(params.channel)
    if (!channel) return
    let shouldMute = false
    if (params.value === '1') shouldMute = true
    channel.mute(shouldMute)
  }
}

joi-browser

joi object schema validation bundled for the browser

BSD-3-Clause
Latest version published 6 years ago

Package Health Score

54 / 100
Full package analysis

Popular joi-browser functions

Similar packages