Skip to content

Commit

Permalink
- Responded to self-review feedback and also fixed tests to hopefully…
Browse files Browse the repository at this point in the history
… get it to pass
  • Loading branch information
heath-freenome committed Jun 24, 2022
1 parent 11f0028 commit edc774b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
6 changes: 2 additions & 4 deletions packages/validator-ajv6/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ Exports `validator-ajv6` plugin for `react-jsonschema-form`.

### Prerequisites

#### React JsonSchema Form
#### React JsonSchema Form Utils

- `@rjsf/core >= 5.0.0`
- `@rjsf/utils >= 5.0.0`

```bash
yarn add @rjsf/core
Expand All @@ -76,8 +76,6 @@ yarn add @rjsf/validator-ajv6

## Usage

### Material UI version 4

```jsx
import Form from '@rjsf/core';
import validator from '@rjsf/validator-ajv6';
Expand Down
4 changes: 2 additions & 2 deletions packages/validator-ajv6/src/createAjvInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export default function createAjvInstance(
ajv.addFormat('color', COLOR_FORMAT_REGEX);

// add more schemas to validate against
if (additionalMetaSchemas && Array.isArray(additionalMetaSchemas)) {
if (Array.isArray(additionalMetaSchemas)) {
ajv.addMetaSchema(additionalMetaSchemas);
}

// add more custom formats to validate against
if (customFormats && isObject(customFormats)) {
if (isObject(customFormats)) {
Object.keys(customFormats).forEach(formatName => {
ajv.addFormat(formatName, customFormats[formatName]);
});
Expand Down
4 changes: 2 additions & 2 deletions packages/validator-ajv6/test/createAjvInstance.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ describe('createAjvInstance()', () => {
expect(ajv.addFormat).toHaveBeenNthCalledWith(2, 'color', COLOR_FORMAT_REGEX);
});
it('the remaining addForma() calls were for custom formats', () => {
Object.keys(CUSTOM_OPTIONS.customFormats).forEach((key: string, i: number) => {
expect(ajv.addFormat).toHaveBeenNthCalledWith(3 + i, key, CUSTOM_OPTIONS.customFormats[key]);
Object.keys(CUSTOM_OPTIONS!.customFormats).forEach((key: string, i: number) => {
expect(ajv.addFormat).toHaveBeenNthCalledWith(3 + i, key, CUSTOM_OPTIONS!.customFormats[key]);
});
});
it('addMetaSchema was not called', () => {
Expand Down

0 comments on commit edc774b

Please sign in to comment.