diff --git a/CHANGELOG.md b/CHANGELOG.md index ad035780ee..0c3f11ec43 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -72,15 +72,17 @@ should change the heading of the (upcoming) version to include a major version b ## @rjsf/validator-ajv8 - Updated `transformRJSFValidationErrors()` to include the `title` property of a field with error fixing #4504 with [PR](https://github.com/rjsf-team/react-jsonschema-form/pull/4700) +- Updated `AJVValidator` to handle the attempted compile of a bad schema, fixing [#4357](https://github.com/rjsf-team/react-jsonschema-form/issues/4357) ## Dev / docs / playground -- Added comprehensive documentation for dynamic UI schema feature with TypeScript examples ([#4706](https://github.com/rjsf-team/react-jsonschema-form/pull/4706)) -- Updated array documentation to reference the new dynamic UI schema capabilities ([#4706](https://github.com/rjsf-team/react-jsonschema-form/pull/4706)) +- Added comprehensive documentation for dynamic UI schema feature with TypeScript examples [#4706](https://github.com/rjsf-team/react-jsonschema-form/pull/4706) +- Updated array documentation to reference the new dynamic UI schema capabilities [#4706](https://github.com/rjsf-team/react-jsonschema-form/pull/4706) - Updated nearly all of the libraries in the `package.json` files to the latest non-breaking versions - Fixed the broken `Custom Array` sample - Improved the `Any Of with Custom Field` sample so that it renders using the appropriate theme components - Updated the `custom-widgets-fields.md` and `v6.x upgrade guide.md` to document the BREAKING CHANGE to the `FieldProps.onChange` behavior +- Updated the playground to properly output the `validationError` when running `Raw Validate` # 6.0.0-beta.13 diff --git a/packages/playground/src/components/RawValidatorTest.tsx b/packages/playground/src/components/RawValidatorTest.tsx index 766b0050ac..7c8833111f 100644 --- a/packages/playground/src/components/RawValidatorTest.tsx +++ b/packages/playground/src/components/RawValidatorTest.tsx @@ -16,7 +16,20 @@ export default function RawValidatorTest({ validator, schema, formData }: RawVal if (rawValidation) { displayErrors = rawValidation.errors || rawValidation.validationError - ? JSON.stringify(rawValidation, null, 2) + ? JSON.stringify( + rawValidation, + (_, value: any) => { + if (value instanceof Error) { + return { + name: value.name, + message: value.message, + stack: value.stack, + }; + } + return value; + }, + 2, + ) : 'No AJV errors encountered'; } return ( diff --git a/packages/validator-ajv8/src/validator.ts b/packages/validator-ajv8/src/validator.ts index cfe7ee78d1..8a70e0c123 100644 --- a/packages/validator-ajv8/src/validator.ts +++ b/packages/validator-ajv8/src/validator.ts @@ -62,10 +62,10 @@ export default class AJV8Validator(schema: S, formData?: T): RawValidationErrorsType { let compilationError: Error | undefined = undefined; let compiledValidator: ValidateFunction | undefined; - if (schema[ID_KEY]) { - compiledValidator = this.ajv.getSchema(schema[ID_KEY]); - } try { + if (schema[ID_KEY]) { + compiledValidator = this.ajv.getSchema(schema[ID_KEY]); + } if (compiledValidator === undefined) { compiledValidator = this.ajv.compile(schema); }