How to use the uniforms/joinName function in uniforms

To help you get started, we’ve selected a few uniforms 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 vazco / uniforms / packages / uniforms / __tests__ / joinName.ts View on Github external
it('works with empty strings', () => {
    expect(joinName('', 'a', 'b')).toBe('a.b');
    expect(joinName('a', '', 'b')).toBe('a.b');
    expect(joinName('a', 'b', '')).toBe('a.b');
  });
github vazco / uniforms / packages / uniforms / __tests__ / joinName.ts View on Github external
it('works with partials', () => {
    expect(joinName('a', 'b.c.d')).toBe('a.b.c.d');
    expect(joinName('a.b', 'c.d')).toBe('a.b.c.d');
    expect(joinName('a.b.c', 'd')).toBe('a.b.c.d');

    expect(joinName(null, 'a', 'b.c.d')).toEqual(['a', 'b', 'c', 'd']);
    expect(joinName(null, 'a.b', 'c.d')).toEqual(['a', 'b', 'c', 'd']);
    expect(joinName(null, 'a.b.c', 'd')).toEqual(['a', 'b', 'c', 'd']);
  });
});
github vazco / uniforms / packages / uniforms / __tests__ / joinName.ts View on Github external
it('works with empty strings', () => {
    expect(joinName('', 'a', 'b')).toBe('a.b');
    expect(joinName('a', '', 'b')).toBe('a.b');
    expect(joinName('a', 'b', '')).toBe('a.b');
  });
github vazco / uniforms / packages / uniforms / __tests__ / joinName.ts View on Github external
it('works with partials', () => {
    expect(joinName('a', 'b.c.d')).toBe('a.b.c.d');
    expect(joinName('a.b', 'c.d')).toBe('a.b.c.d');
    expect(joinName('a.b.c', 'd')).toBe('a.b.c.d');

    expect(joinName(null, 'a', 'b.c.d')).toEqual(['a', 'b', 'c', 'd']);
    expect(joinName(null, 'a.b', 'c.d')).toEqual(['a', 'b', 'c', 'd']);
    expect(joinName(null, 'a.b.c', 'd')).toEqual(['a', 'b', 'c', 'd']);
  });
});
github vazco / uniforms / packages / uniforms / __tests__ / joinName.ts View on Github external
it('works with partials', () => {
    expect(joinName('a', 'b.c.d')).toBe('a.b.c.d');
    expect(joinName('a.b', 'c.d')).toBe('a.b.c.d');
    expect(joinName('a.b.c', 'd')).toBe('a.b.c.d');

    expect(joinName(null, 'a', 'b.c.d')).toEqual(['a', 'b', 'c', 'd']);
    expect(joinName(null, 'a.b', 'c.d')).toEqual(['a', 'b', 'c', 'd']);
    expect(joinName(null, 'a.b.c', 'd')).toEqual(['a', 'b', 'c', 'd']);
  });
});
github vazco / uniforms / packages / uniforms-bridge-json-schema / src / JSONSchemaBridge.ts View on Github external
getInitialValue(name, props: any = {}) {
    const { default: _default, type: _type } = this.getField(name);
    const {
      default: defaultValue = _default !== undefined
        ? _default
        : get(this.schema.default, name),
      type = _type
    } = this._compiledSchema[name];

    if (defaultValue !== undefined) return cloneDeep(defaultValue);

    if (type === 'array') {
      const item = this.getInitialValue(joinName(name, '0'));
      const items = props.initialCount || 0;
      return Array(items).fill(item);
    }

    if (type === 'object') return {};

    return undefined;
  }
github vazco / uniforms / packages / uniforms-semantic / src / ListItemField.js View on Github external
Children.map(props.children, child =>
          React.cloneElement(child, {
            name: joinName(props.name, child.props.name),
            label: null,
            style: {
              margin: 0,
              ...child.props.style
            }
          })
        )
github vazco / uniforms / packages / uniforms-bridge-json-schema / src / JSONSchemaBridge.ts View on Github external
getField(name) {
    return joinName(null, name).reduce((definition, next, nextIndex, array) => {
      const previous = joinName(array.slice(0, nextIndex));
      const isRequired = (
        definition.required ||
        (this._compiledSchema[previous] || {}).required ||
        []
      ).includes(next);

      const _key = joinName(previous, next);
      const _definition = this._compiledSchema[_key] || {};

      if (next === '$' || next === '' + parseInt(next, 10)) {
        invariant(
          definition.type === 'array',
          'Field not found in schema: "%s"',
          name
        );