@ptolemy2002/regex-utils 2.6.1 → 2.6.2
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/README.md +10 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -151,6 +151,16 @@ Checks if a string is a valid set of regular expression flags.
|
|
|
151
151
|
#### Returns
|
|
152
152
|
`boolean` - `true` if the string is a valid set of regular expression flags, `false` otherwise.
|
|
153
153
|
|
|
154
|
+
### isZodError
|
|
155
|
+
#### Description
|
|
156
|
+
Checks if an unknown value is a ZodError. This is more reliable than using `instanceof` as it also checks for the name property. This is particularly important in projects with multiple versions of zod, where instanceof checks may fail due to different constructor references.
|
|
157
|
+
|
|
158
|
+
#### Parameters
|
|
159
|
+
- `err` (`unknown`): The value to be checked.
|
|
160
|
+
|
|
161
|
+
#### Returns
|
|
162
|
+
`boolean` - `true` if the value is a ZodError, `false` otherwise.
|
|
163
|
+
|
|
154
164
|
### interpretZodError
|
|
155
165
|
#### Description
|
|
156
166
|
Given a zod error, interprets it to `null` if no error is found, a single error message if there is a single error, or an array of error messages if there are multiple errors. The error messages will be in the format `<path>: <message>`. If the error is with function arguments, "arguments.<index>" will be appended to the end of the path. Similarly, if the error is with a function return value, "returnValue" will be appended to the end of the path. Note that for function arguments, only the first seen error will be reported.
|