hh-contracts 0.0.91 → 0.0.92

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.
@@ -29,4 +29,3 @@ __exportStar(require("./role-types.constant"), exports);
29
29
  __exportStar(require("./route-component-key.constants"), exports);
30
30
  __exportStar(require("./slug.constant"), exports);
31
31
  __exportStar(require("./translatable-field.constant"), exports);
32
- __exportStar(require("./zod-error-mapping.constant"), exports);
@@ -36,5 +36,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.makeTranslationsByLang = void 0;
37
37
  const z = __importStar(require("zod"));
38
38
  const language_keys_schema_1 = require("./language-keys.schema");
39
- const makeTranslationsByLang = (schema) => z.partialRecord(language_keys_schema_1.LanguageKeysSchema, schema);
39
+ const makeTranslationsByLang = (schema) => z
40
+ .partialRecord(language_keys_schema_1.LanguageKeysSchema, schema)
41
+ .refine(translations => Object.keys(translations).length > 0, {
42
+ params: {
43
+ messageKey: 'zod.translations.must_not_be_empty',
44
+ },
45
+ });
40
46
  exports.makeTranslationsByLang = makeTranslationsByLang;
@@ -13,4 +13,3 @@ export * from './role-types.constant';
13
13
  export * from './route-component-key.constants';
14
14
  export * from './slug.constant';
15
15
  export * from './translatable-field.constant';
16
- export * from './zod-error-mapping.constant';
@@ -2,7 +2,13 @@ import * as z from 'zod';
2
2
  import { LanguageKeysSchema } from './language-keys.schema';
3
3
 
4
4
  export const makeTranslationsByLang = <T extends z.ZodObject>(schema: T) =>
5
- z.partialRecord(LanguageKeysSchema, schema);
5
+ z
6
+ .partialRecord(LanguageKeysSchema, schema)
7
+ .refine(translations => Object.keys(translations).length > 0, {
8
+ params: {
9
+ messageKey: 'zod.translations.must_not_be_empty',
10
+ },
11
+ });
6
12
  export type TranslationsByLang<T extends object> = Partial<
7
13
  Record<z.infer<typeof LanguageKeysSchema>, T>
8
14
  >;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hh-contracts",
3
- "version": "0.0.91",
3
+ "version": "0.0.92",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "scripts": {
@@ -1,46 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ZOD_ERROR_MAPPING = void 0;
37
- const z = __importStar(require("zod"));
38
- exports.ZOD_ERROR_MAPPING = {
39
- [z.ZodIssueCode.invalid_type]: 'errors.validation.invalidType',
40
- [z.ZodIssueCode.custom]: 'errors.validation.custom',
41
- [z.ZodIssueCode.invalid_union]: 'errors.validation.invalidUnion',
42
- [z.ZodIssueCode.unrecognized_keys]: 'errors.validation.unrecognizedKeys',
43
- [z.ZodIssueCode.too_small]: 'errors.validation.tooSmall',
44
- [z.ZodIssueCode.too_big]: 'errors.validation.tooBig',
45
- [z.ZodIssueCode.not_multiple_of]: 'errors.validation.notMultipleOf',
46
- };
@@ -1,13 +0,0 @@
1
- import * as z from 'zod';
2
-
3
- export const ZOD_ERROR_MAPPING = {
4
- [z.ZodIssueCode.invalid_type]: 'errors.validation.invalidType',
5
- [z.ZodIssueCode.custom]: 'errors.validation.custom',
6
- [z.ZodIssueCode.invalid_union]: 'errors.validation.invalidUnion',
7
- [z.ZodIssueCode.unrecognized_keys]: 'errors.validation.unrecognizedKeys',
8
- [z.ZodIssueCode.too_small]: 'errors.validation.tooSmall',
9
- [z.ZodIssueCode.too_big]: 'errors.validation.tooBig',
10
- [z.ZodIssueCode.not_multiple_of]: 'errors.validation.notMultipleOf',
11
- };
12
-
13
- export type TZodErorrKey = (typeof ZOD_ERROR_MAPPING)[keyof typeof ZOD_ERROR_MAPPING];