@rjsf/utils 5.19.2 → 5.19.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/enums.ts CHANGED
@@ -55,18 +55,25 @@ export enum TranslatableString {
55
55
  /** Key label, where %1 will be replaced by the label as provided by WrapIfAdditionalTemplate */
56
56
  KeyLabel = '%1 Key',
57
57
  // Strings with replaceable parameters AND/OR that support markdown and html
58
- /** Invalid object field configuration as provided by the ObjectField */
59
- InvalidObjectField = 'Invalid "%1" object field configuration: <em>%2</em>.',
58
+ /** Invalid object field configuration as provided by the ObjectField.
59
+ * NOTE: Use markdown notation rather than html tags.
60
+ */
61
+ InvalidObjectField = 'Invalid "%1" object field configuration: _%2_.',
60
62
  /** Unsupported field schema, used by UnsupportedField */
61
63
  UnsupportedField = 'Unsupported field schema.',
62
- /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField */
63
- UnsupportedFieldWithId = 'Unsupported field schema for field <code>%1</code>.',
64
- /** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField */
65
- UnsupportedFieldWithReason = 'Unsupported field schema: <em>%1</em>.',
64
+ /** Unsupported field schema, where %1 will be replaced by the idSchema.$id as provided by UnsupportedField.
65
+ * NOTE: Use markdown notation rather than html tags.
66
+ */
67
+ UnsupportedFieldWithId = 'Unsupported field schema for field `%1`.',
68
+ /** Unsupported field schema, where %1 will be replaced by the reason string as provided by UnsupportedField.
69
+ * NOTE: Use markdown notation rather than html tags.
70
+ */
71
+ UnsupportedFieldWithReason = 'Unsupported field schema: _%1_.',
66
72
  /** Unsupported field schema, where %1 and %2 will be replaced by the idSchema.$id and reason strings, respectively,
67
- * as provided by UnsupportedField
73
+ * as provided by UnsupportedField.
74
+ * NOTE: Use markdown notation rather than html tags.
68
75
  */
69
- UnsupportedFieldWithIdAndReason = 'Unsupported field schema for field <code>%1</code>: <em>%2</em>.',
76
+ UnsupportedFieldWithIdAndReason = 'Unsupported field schema for field `%1`: _%2_.',
70
77
  /** File name, type and size info, where %1, %2 and %3 will be replaced by the file name, file type and file size as
71
78
  * provided by FileWidget
72
79
  */
@@ -48,6 +48,12 @@ export default class ParserValidator<T = any, S extends StrictRJSFSchema = RJSFS
48
48
  this.addSchema(rootSchema, hashForSchema<S>(rootSchema));
49
49
  }
50
50
 
51
+ /** Resets the internal AJV validator to clear schemas from it. Can be helpful for resetting the validator for tests.
52
+ */
53
+ reset() {
54
+ this.schemaMap = {};
55
+ }
56
+
51
57
  /** Adds the given `schema` to the `schemaMap` keyed by the `hash` or `ID_KEY` if present on the `schema`. If the
52
58
  * schema does not have an `ID_KEY`, then the `hash` will be added as the `ID_KEY` to allow the schema to be
53
59
  * associated with it's `hash` for future use (by a schema compiler).
package/src/types.ts CHANGED
@@ -1004,6 +1004,10 @@ export interface ValidatorType<T = any, S extends StrictRJSFSchema = RJSFSchema,
1004
1004
  * @param formData - The form data to validate
1005
1005
  */
1006
1006
  rawValidation<Result = any>(schema: S, formData?: T): { errors?: Result[]; validationError?: Error };
1007
+ /** An optional function that can be used to reset validator implementation. Useful for clear schemas in the AJV
1008
+ * instance for tests.
1009
+ */
1010
+ reset?: () => void;
1007
1011
  }
1008
1012
 
1009
1013
  /** The `SchemaUtilsType` interface provides a wrapper around the publicly exported APIs in the `@rjsf/utils/schema`