How to use uniforms-bridge-json-schema - 10 common examples

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);
    });
  });
github vazco / uniforms / packages / uniforms-bridge-json-schema / __tests__ / JSONSchemaBridge.ts View on Github external
it('always returns false', () => {
      expect(JSONSchemaBridge.check()).not.toBeTruthy();
      expect(JSONSchemaBridge.check(bridge)).not.toBeTruthy();
      expect(JSONSchemaBridge.check(schema)).not.toBeTruthy();
      expect(JSONSchemaBridge.check(validator)).not.toBeTruthy();
    });
  });
github vazco / uniforms / packages / uniforms-bridge-json-schema / __tests__ / JSONSchemaBridge.ts View on Github external
it('always returns false', () => {
      expect(JSONSchemaBridge.check()).not.toBeTruthy();
      expect(JSONSchemaBridge.check(bridge)).not.toBeTruthy();
      expect(JSONSchemaBridge.check(schema)).not.toBeTruthy();
      expect(JSONSchemaBridge.check(validator)).not.toBeTruthy();
    });
  });
github vazco / uniforms / packages / uniforms-bridge-json-schema / __tests__ / JSONSchemaBridge.ts View on Github external
it('always returns false', () => {
      expect(JSONSchemaBridge.check()).not.toBeTruthy();
      expect(JSONSchemaBridge.check(bridge)).not.toBeTruthy();
      expect(JSONSchemaBridge.check(schema)).not.toBeTruthy();
      expect(JSONSchemaBridge.check(validator)).not.toBeTruthy();
    });
  });
github vazco / uniforms / packages / uniforms-bridge-json-schema / __tests__ / JSONSchemaBridge.ts View on Github external
it('always returns false', () => {
      expect(JSONSchemaBridge.check()).not.toBeTruthy();
      expect(JSONSchemaBridge.check(bridge)).not.toBeTruthy();
      expect(JSONSchemaBridge.check(schema)).not.toBeTruthy();
      expect(JSONSchemaBridge.check(validator)).not.toBeTruthy();
    });
  });
github vazco / uniforms / docs / examples / CustomFields / DisplayIfFieldSchema.js View on Github external
function createValidator(schema) {
  const validator = ajv.compile(schema);

  return model => {
    validator(model);

    if (validator.errors && validator.errors.length) {
      throw { details: validator.errors };
    }
  };
}

const schemaValidator = createValidator(schema);

export default new JSONSchemaBridge(schema, schemaValidator);
github vazco / uniforms / docs / examples / CustomFields / CycleFieldSchema.js View on Github external
function createValidator(schema) {
  const validator = ajv.compile(schema);

  return model => {
    validator(model);

    if (validator.errors && validator.errors.length) {
      throw { details: validator.errors };
    }
  };
}

const schemaValidator = createValidator(schema);

export default new JSONSchemaBridge(schema, schemaValidator);

uniforms-bridge-json-schema

JSONSchema schema bridge for uniforms.

MIT
Latest version published 1 month ago

Package Health Score

72 / 100
Full package analysis