How to use the uniforms-bridge-json-schema/JSONSchemaBridge function in uniforms-bridge-json-schema

To help you get started, we’ve selected a few uniforms-bridge-json-schema 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-bridge-json-schema / __tests__ / JSONSchemaBridge.ts View on Github external
}
                  }
                }
              }
            }
          }
        }
      },
      password: { type: 'string', uniforms: { type: 'password' } },
      passwordNumeric: { type: 'number', uniforms: { type: 'password' } }
    },
    required: ['dateOfBirth']
  };

  const validator = jest.fn();
  const bridge = new JSONSchemaBridge(schema, validator);

  describe('#constructor()', () => {
    it('sets schema correctly when has top level type of object', () => {
      expect(bridge.schema).toEqual(schema);
    });

    it('sets schema correctly when has top level $ref', () => {
      const localSchema = {
        definitions: schema.definitions,
        $ref: '#/definitions/personalData'
      };
      const localBridge = new JSONSchemaBridge(localSchema, validator);
      expect(localBridge.schema).toEqual({
        ...localSchema,
        ...localSchema.definitions.personalData
      });
github vazco / uniforms / packages / uniforms-bridge-json-schema / __tests__ / JSONSchemaBridge.ts View on Github external
it('throws when resolving field schema is not possible', () => {
      const localBridge = new JSONSchemaBridge(
        { definitions: schema.definitions, $ref: '#/definitions/personalData' },
        validator
      );

      expect(() => localBridge.getField('invalid')).toThrow(
        /Field not found in schema/
      );
    });
  });
github vazco / uniforms / packages / uniforms-bridge-json-schema / __tests__ / JSONSchemaBridge.ts View on Github external
it('works on top level when schema does not have properties', () => {
      const localBridge = new JSONSchemaBridge(
        { definitions: schema.definitions, $ref: '#/definitions/lastName' },
        validator
      );

      expect(localBridge.getSubfields()).toEqual([]);
    });
  });
github vazco / uniforms / packages / uniforms-bridge-json-schema / __tests__ / JSONSchemaBridge.ts View on Github external
it('falls back to input schema', () => {
      const localSchema = { definitions: schema.definitions };
      const localBridge = new JSONSchemaBridge(localSchema, validator);
      expect(localBridge.schema).toEqual(localSchema);
    });
  });

uniforms-bridge-json-schema

JSONSchema schema bridge for uniforms.

MIT
Latest version published 2 days ago

Package Health Score

72 / 100
Full package analysis