Skip to content

Commit fbb53e9

Browse files
committed
Validator to support AJV $data reference and saving validator state in ShareURL.
1 parent 433f99b commit fbb53e9

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

packages/playground/src/app.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ const esV8Validator = customizeValidator({}, localize_es);
2020
const AJV8_2019 = customizeValidator({ AjvClass: Ajv2019 });
2121
const AJV8_2020 = customizeValidator({ AjvClass: Ajv2020 });
2222
const AJV8_DISC = customizeValidator({ ajvOptionsOverrides: { discriminator: true } });
23+
const AJV8_DATA_REF = customizeValidator({ ajvOptionsOverrides: { $data: true } });
2324

2425
const validators: PlaygroundProps['validators'] = {
2526
AJV8: v8Validator,
27+
'AJV8 $data reference': AJV8_DATA_REF,
2628
'AJV8 (discriminator)': AJV8_DISC,
2729
AJV8_es: esV8Validator,
2830
AJV8_2019,

packages/playground/src/components/Header.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,7 @@ export default function Header({
306306
uiSchema,
307307
theme,
308308
liveSettings,
309+
validator,
309310
})
310311
);
311312

@@ -314,7 +315,7 @@ export default function Header({
314315
setShareURL(null);
315316
console.error(error);
316317
}
317-
}, [formData, liveSettings, schema, theme, uiSchema, setShareURL]);
318+
}, [formData, liveSettings, schema, theme, uiSchema, validator, setShareURL]);
318319

319320
return (
320321
<div className='page-header'>

packages/playground/src/components/Playground.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export default function Playground({ themes, validators }: PlaygroundProps) {
6969
theme: dataTheme = theme,
7070
extraErrors,
7171
liveSettings,
72+
validator,
7273
...rest
7374
} = data;
7475

@@ -85,6 +86,7 @@ export default function Playground({ themes, validators }: PlaygroundProps) {
8586
setTheme(theTheme);
8687
setShowForm(true);
8788
setLiveSettings(liveSettings);
89+
setValidator(validator);
8890
setOtherFormProps({ fields, templates, ...rest });
8991
},
9092
[theme, onThemeSelected, themes]
Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
import { FormProps } from '@rjsf/core';
22

3-
export type Sample = Omit<FormProps, 'validator'>;
3+
export interface Sample extends Omit<FormProps, 'validator'> {
4+
validator: string;
5+
}

0 commit comments

Comments
 (0)