zod-error-map 0.1.0 → 0.2.1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zod-error-map",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Type-safe, customizable error message mapping for Zod validation",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -0,0 +1,4 @@
1
+ export {
2
+ setZodErrorMap,
3
+ createZodErrorMap,
4
+ } from './zod/index.js'
@@ -0,0 +1,4 @@
1
+ export {
2
+ setZodErrorMap,
3
+ createZodErrorMap,
4
+ } from './integration.js'
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @typedef {import('./types.js').ErrorMapConfig} ErrorMapConfig
2
+ * @typedef {import('../../core/types/index.js').ErrorMapConfig} ErrorMapConfig
3
3
  */
4
4
 
5
- import { createErrorMapper } from './error-mapper.js'
5
+ import { createErrorMapper } from '../../domain/mappers/index.js'
6
6
 
7
7
  /**
8
8
  * Sets the global Zod error map using z.config()
@@ -0,0 +1 @@
1
+ export { ErrorCode, FormatType } from './error-codes.js'
@@ -0,0 +1 @@
1
+ export { ErrorCode, FormatType } from './constants/index.js'
@@ -0,0 +1,10 @@
1
+ export {
2
+ getInputDescription,
3
+ defaultFormatMessages,
4
+ buildInvalidTypeMessage,
5
+ buildTooSmallMessage,
6
+ buildTooBigMessage,
7
+ createFormatMessageBuilder,
8
+ createCustomMessageBuilder,
9
+ createDefaultBuilders,
10
+ } from './message-builders.js'
@@ -1,9 +1,9 @@
1
- import { ErrorCode, FormatType } from './error-codes.js'
1
+ import { ErrorCode, FormatType } from '../../core/constants/index.js'
2
2
 
3
3
  /**
4
- * @typedef {import('./types.js').RawIssue} RawIssue
5
- * @typedef {import('./types.js').Label} Label
6
- * @typedef {import('./types.js').MessageBuilder} MessageBuilder
4
+ * @typedef {import('../../core/types/index.js').RawIssue} RawIssue
5
+ * @typedef {import('../../core/types/index.js').Label} Label
6
+ * @typedef {import('../../core/types/index.js').MessageBuilder} MessageBuilder
7
7
  */
8
8
 
9
9
  /**
@@ -25,7 +25,7 @@ export function getInputDescription(input) {
25
25
  export const defaultFormatMessages = {
26
26
  [FormatType.EMAIL]: (label) => `The ${label.quoted} must be a valid email address`,
27
27
  [FormatType.UUID]: (label) => `The ${label.quoted} must be a valid UUID`,
28
- [FormatType.URL]: (label) => `The ${label.quoted} must be a valid URL`,
28
+ [FormatType.URL]: (label) => `The ${label.quoted} is invalid`,
29
29
  [FormatType.REGEX]: (label) => `The ${label.quoted} has an invalid format`,
30
30
  [FormatType.CUID]: (label) => `The ${label.quoted} must be a valid CUID`,
31
31
  [FormatType.CUID2]: (label) => `The ${label.quoted} must be a valid CUID2`,
@@ -0,0 +1,15 @@
1
+ export {
2
+ createErrorMapper,
3
+ defaultErrorMapper,
4
+ } from './mappers/index.js'
5
+
6
+ export {
7
+ getInputDescription,
8
+ defaultFormatMessages,
9
+ buildInvalidTypeMessage,
10
+ buildTooSmallMessage,
11
+ buildTooBigMessage,
12
+ createFormatMessageBuilder,
13
+ createCustomMessageBuilder,
14
+ createDefaultBuilders,
15
+ } from './builders/index.js'
@@ -1,10 +1,10 @@
1
- import { createDefaultBuilders } from './message-builders.js'
1
+ import { createDefaultBuilders } from '../builders/index.js'
2
2
 
3
3
  /**
4
- * @typedef {import('./types.js').RawIssue} RawIssue
5
- * @typedef {import('./types.js').Label} Label
6
- * @typedef {import('./types.js').MessageBuilder} MessageBuilder
7
- * @typedef {import('./types.js').ErrorMapConfig} ErrorMapConfig
4
+ * @typedef {import('../../core/types/index.js').RawIssue} RawIssue
5
+ * @typedef {import('../../core/types/index.js').Label} Label
6
+ * @typedef {import('../../core/types/index.js').MessageBuilder} MessageBuilder
7
+ * @typedef {import('../../core/types/index.js').ErrorMapConfig} ErrorMapConfig
8
8
  */
9
9
 
10
10
  const DEFAULT_ERROR = 'Invalid input'
@@ -0,0 +1,4 @@
1
+ export {
2
+ createErrorMapper,
3
+ defaultErrorMapper,
4
+ } from './error-mapper.js'
package/src/index.js CHANGED
@@ -1,11 +1,8 @@
1
- export { ErrorCode, FormatType } from './error-codes.js'
1
+ export { ErrorCode, FormatType } from './core/index.js'
2
2
 
3
3
  export {
4
4
  createErrorMapper,
5
5
  defaultErrorMapper,
6
- } from './error-mapper.js'
7
-
8
- export {
9
6
  getInputDescription,
10
7
  defaultFormatMessages,
11
8
  buildInvalidTypeMessage,
@@ -14,9 +11,9 @@ export {
14
11
  createFormatMessageBuilder,
15
12
  createCustomMessageBuilder,
16
13
  createDefaultBuilders,
17
- } from './message-builders.js'
14
+ } from './domain/index.js'
18
15
 
19
16
  export {
20
17
  setZodErrorMap,
21
18
  createZodErrorMap,
22
- } from './zod-integration.js'
19
+ } from './adapters/index.js'
File without changes