nextjs-cms 0.9.2 → 0.9.3
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/dist/validators/checkbox.d.ts +1 -1
- package/dist/validators/checkbox.d.ts.map +1 -1
- package/dist/validators/checkbox.js +3 -3
- package/dist/validators/color.d.ts +1 -1
- package/dist/validators/color.d.ts.map +1 -1
- package/dist/validators/color.js +3 -3
- package/dist/validators/date.d.ts +1 -1
- package/dist/validators/date.d.ts.map +1 -1
- package/dist/validators/date.js +2 -2
- package/dist/validators/document.d.ts +1 -1
- package/dist/validators/document.d.ts.map +1 -1
- package/dist/validators/document.js +6 -6
- package/dist/validators/map.d.ts +1 -1
- package/dist/validators/map.d.ts.map +1 -1
- package/dist/validators/map.js +3 -3
- package/dist/validators/number.d.ts +1 -1
- package/dist/validators/number.d.ts.map +1 -1
- package/dist/validators/number.js +6 -6
- package/dist/validators/password.d.ts +1 -1
- package/dist/validators/password.d.ts.map +1 -1
- package/dist/validators/password.js +4 -4
- package/dist/validators/photo.d.ts +1 -1
- package/dist/validators/photo.d.ts.map +1 -1
- package/dist/validators/photo.js +12 -12
- package/dist/validators/richText.d.ts +1 -1
- package/dist/validators/richText.d.ts.map +1 -1
- package/dist/validators/richText.js +4 -4
- package/dist/validators/select-multiple.d.ts +1 -1
- package/dist/validators/select-multiple.d.ts.map +1 -1
- package/dist/validators/select-multiple.js +3 -3
- package/dist/validators/select.d.ts +1 -1
- package/dist/validators/select.d.ts.map +1 -1
- package/dist/validators/select.js +2 -2
- package/dist/validators/slug.d.ts +1 -1
- package/dist/validators/slug.d.ts.map +1 -1
- package/dist/validators/slug.js +5 -5
- package/dist/validators/text.d.ts +1 -1
- package/dist/validators/text.d.ts.map +1 -1
- package/dist/validators/text.js +4 -4
- package/dist/validators/textarea.d.ts +1 -1
- package/dist/validators/textarea.d.ts.map +1 -1
- package/dist/validators/textarea.js +4 -4
- package/dist/validators/video.d.ts +1 -1
- package/dist/validators/video.d.ts.map +1 -1
- package/dist/validators/video.js +6 -6
- package/package.json +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { CheckboxFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const checkboxFieldSchema: (field: CheckboxFieldClientConfig,
|
|
3
|
+
export declare const checkboxFieldSchema: (field: CheckboxFieldClientConfig, language?: string) => z.ZodPipe<z.ZodTransform<{} | undefined, unknown>, z.ZodOptional<z.ZodBoolean>>;
|
|
4
4
|
//# sourceMappingURL=checkbox.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/validators/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"checkbox.d.ts","sourceRoot":"","sources":["../../src/validators/checkbox.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,iBAAe,oFAYpF,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const checkboxFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const checkboxFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
// Normalize typical form values
|
|
6
6
|
const normalized = z.preprocess((v) => {
|
|
7
7
|
if (v === 'on')
|
|
@@ -11,6 +11,6 @@ export const checkboxFieldSchema = (field, locale = 'en') => {
|
|
|
11
11
|
return v;
|
|
12
12
|
}, z.boolean(requiredMessage).optional());
|
|
13
13
|
return field.required
|
|
14
|
-
? normalized.refine((v) => v === true, { message: getString('checkboxRequired',
|
|
14
|
+
? normalized.refine((v) => v === true, { message: getString('checkboxRequired', language) })
|
|
15
15
|
: normalized; // allows undefined (unchecked) or a boolean if sent explicitly
|
|
16
16
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { ColorFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const colorFieldSchema: (field: ColorFieldClientConfig,
|
|
3
|
+
export declare const colorFieldSchema: (field: ColorFieldClientConfig, language?: string) => z.ZodString | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
|
|
4
4
|
//# sourceMappingURL=color.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/validators/color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAGrE,eAAO,MAAM,gBAAgB,GAAI,OAAO,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/validators/color.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAGrE,eAAO,MAAM,gBAAgB,GAAI,OAAO,sBAAsB,EAAE,iBAAe,sFAO9E,CAAA"}
|
package/dist/validators/color.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const colorFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const colorFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const base = z.string(requiredMessage).regex(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/, {
|
|
6
|
-
message: getString('invalidColorFormat',
|
|
6
|
+
message: getString('invalidColorFormat', language),
|
|
7
7
|
});
|
|
8
8
|
return field.required ? base : z.union([z.literal(''), base], requiredMessage).optional();
|
|
9
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { DateFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const dateFieldSchema: (field: DateFieldClientConfig,
|
|
3
|
+
export declare const dateFieldSchema: (field: DateFieldClientConfig, language?: string) => z.ZodDate | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodDate]>>;
|
|
4
4
|
//# sourceMappingURL=date.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/validators/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAGpE,eAAO,MAAM,eAAe,GAAI,OAAO,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/validators/date.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAGpE,eAAO,MAAM,eAAe,GAAI,OAAO,qBAAqB,EAAE,iBAAe,kFAK5E,CAAA"}
|
package/dist/validators/date.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const dateFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const dateFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const base = z.date(requiredMessage);
|
|
6
6
|
return field.required ? base : z.union([z.literal(''), base], requiredMessage).optional();
|
|
7
7
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { DocumentFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const documentFieldSchema: (field: DocumentFieldClientConfig,
|
|
3
|
+
export declare const documentFieldSchema: (field: DocumentFieldClientConfig, language?: string) => z.ZodCustom<File, File> | z.ZodOptional<z.ZodUnion<readonly [z.ZodNull, z.ZodUndefined, z.ZodCustom<File, File>]>>;
|
|
4
4
|
//# sourceMappingURL=document.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/validators/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"document.d.ts","sourceRoot":"","sources":["../../src/validators/document.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,iBAAe,uHA6DpF,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const documentFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const documentFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
/**
|
|
6
6
|
* Construct a custom schema for the document field
|
|
7
7
|
*/
|
|
@@ -11,7 +11,7 @@ export const documentFieldSchema = (field, locale = 'en') => {
|
|
|
11
11
|
if (field.required) {
|
|
12
12
|
ctx.addIssue({
|
|
13
13
|
code: z.ZodIssueCode.custom,
|
|
14
|
-
message: getString('noFileSelected',
|
|
14
|
+
message: getString('noFileSelected', language),
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
return; // If it's not required, do nothing (no issue).
|
|
@@ -22,7 +22,7 @@ export const documentFieldSchema = (field, locale = 'en') => {
|
|
|
22
22
|
if (!field.extensions.includes(file.name.split('.').pop())) {
|
|
23
23
|
ctx.addIssue({
|
|
24
24
|
code: z.ZodIssueCode.custom,
|
|
25
|
-
message: getString('invalidFileExtension',
|
|
25
|
+
message: getString('invalidFileExtension', language, { extensions: field.extensions.join(', ') }),
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -39,7 +39,7 @@ export const documentFieldSchema = (field, locale = 'en') => {
|
|
|
39
39
|
origin: 'number',
|
|
40
40
|
inclusive: true,
|
|
41
41
|
type: 'number',
|
|
42
|
-
message: getString('fileSizeExceeded',
|
|
42
|
+
message: getString('fileSizeExceeded', language, { size: field.maxFileSize.size, unit: field.maxFileSize.unit }),
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -48,7 +48,7 @@ export const documentFieldSchema = (field, locale = 'en') => {
|
|
|
48
48
|
if (!field.mimeType.includes(file.type)) {
|
|
49
49
|
ctx.addIssue({
|
|
50
50
|
code: 'custom',
|
|
51
|
-
message: getString('invalidDocumentType',
|
|
51
|
+
message: getString('invalidDocumentType', language, { types: field.mimeType.join(', ') }),
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
});
|
package/dist/validators/map.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { MapFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const mapFieldSchema: (field: MapFieldClientConfig,
|
|
3
|
+
export declare const mapFieldSchema: (field: MapFieldClientConfig, language?: string) => z.ZodString | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
|
|
4
4
|
//# sourceMappingURL=map.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/validators/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAGnE,eAAO,MAAM,cAAc,GAAI,OAAO,oBAAoB,EAAE,
|
|
1
|
+
{"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/validators/map.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAA;AAGnE,eAAO,MAAM,cAAc,GAAI,OAAO,oBAAoB,EAAE,iBAAe,sFAO1E,CAAA"}
|
package/dist/validators/map.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const mapFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const mapFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const base = z
|
|
6
6
|
.string(requiredMessage)
|
|
7
|
-
.regex(/^-?\d+(\.\d+)?,-?\d+(\.\d+)?$/, { message: getString('invalidMapFormat',
|
|
7
|
+
.regex(/^-?\d+(\.\d+)?,-?\d+(\.\d+)?$/, { message: getString('invalidMapFormat', language) });
|
|
8
8
|
return field.required ? base : z.union([z.literal(''), base], requiredMessage).optional();
|
|
9
9
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { NumberFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const numberFieldSchema: (field: NumberFieldClientConfig,
|
|
3
|
+
export declare const numberFieldSchema: (field: NumberFieldClientConfig, language?: string) => z.ZodNumber | z.ZodOptional<z.ZodUnion<readonly [z.ZodUndefined, z.ZodNull, z.ZodNaN, z.ZodLiteral<"">, z.ZodNumber]>>;
|
|
4
4
|
//# sourceMappingURL=number.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/validators/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAGtE,eAAO,MAAM,iBAAiB,GAAI,OAAO,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"number.d.ts","sourceRoot":"","sources":["../../src/validators/number.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAGtE,eAAO,MAAM,iBAAiB,GAAI,OAAO,uBAAuB,EAAE,iBAAe,2HA+BhF,CAAA"}
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const numberFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const numberFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
let base = z.number(requiredMessage);
|
|
6
6
|
if (field.minValue != null) {
|
|
7
7
|
base = base.min(field.minValue, {
|
|
8
|
-
message: getString('numberMinValue',
|
|
8
|
+
message: getString('numberMinValue', language, { min: field.minValue }),
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
if (field.maxValue != null) {
|
|
12
12
|
base = base.max(field.maxValue, {
|
|
13
|
-
message: getString('numberMaxValue',
|
|
13
|
+
message: getString('numberMaxValue', language, { max: field.maxValue }),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
if (field.maxLength != null) {
|
|
17
17
|
const maxLength = field.maxLength;
|
|
18
18
|
base = base.refine((val) => val.toString().length <= maxLength, {
|
|
19
|
-
message: getString('numberMaxLength',
|
|
19
|
+
message: getString('numberMaxLength', language, { max: field.maxLength }),
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
if (field.minLength != null) {
|
|
23
23
|
const minLength = field.minLength;
|
|
24
24
|
base = base.refine((val) => val.toString().length >= minLength, {
|
|
25
|
-
message: getString('numberMinLength',
|
|
25
|
+
message: getString('numberMinLength', language, { min: field.minLength }),
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
return field.required ? base : z.union([z.undefined(), z.null(), z.nan(), z.literal(''), base]).optional();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { PasswordFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const passwordFieldSchema: (field: PasswordFieldClientConfig,
|
|
3
|
+
export declare const passwordFieldSchema: (field: PasswordFieldClientConfig, language?: string) => z.ZodString | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
|
|
4
4
|
//# sourceMappingURL=password.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/validators/password.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"password.d.ts","sourceRoot":"","sources":["../../src/validators/password.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,iBAAe,sFAmBpF,CAAA"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const passwordFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const passwordFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const minLength = field.minLength ?? 1;
|
|
6
6
|
const maxLength = field.maxLength ?? Infinity;
|
|
7
7
|
let base = z
|
|
8
8
|
.string(requiredMessage)
|
|
9
9
|
.min(minLength, {
|
|
10
|
-
message: minLength === 1 ? requiredMessage : getString('minLength',
|
|
10
|
+
message: minLength === 1 ? requiredMessage : getString('minLength', language, { min: minLength }),
|
|
11
11
|
});
|
|
12
12
|
if (Number.isFinite(maxLength)) {
|
|
13
|
-
base = base.max(maxLength, { message: getString('maxLength',
|
|
13
|
+
base = base.max(maxLength, { message: getString('maxLength', language, { max: maxLength }) });
|
|
14
14
|
}
|
|
15
15
|
if (field.validation) {
|
|
16
16
|
base = base.regex(field.validation.regex, field.validation.message);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { PhotoFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const photoFieldSchema: (field: PhotoFieldClientConfig,
|
|
3
|
+
export declare const photoFieldSchema: (field: PhotoFieldClientConfig, language?: string) => z.ZodCustom<File, File> | z.ZodOptional<z.ZodUnion<readonly [z.ZodNull, z.ZodUndefined, z.ZodCustom<File, File>]>>;
|
|
4
4
|
//# sourceMappingURL=photo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"photo.d.ts","sourceRoot":"","sources":["../../src/validators/photo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AA6BrE,eAAO,MAAM,gBAAgB,GAAI,OAAO,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"photo.d.ts","sourceRoot":"","sources":["../../src/validators/photo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AA6BrE,eAAO,MAAM,gBAAgB,GAAI,OAAO,sBAAsB,EAAE,iBAAe,uHAmF9E,CAAA"}
|
package/dist/validators/photo.js
CHANGED
|
@@ -3,7 +3,7 @@ import getString from '../translations/index.js';
|
|
|
3
3
|
/**
|
|
4
4
|
* Helper function to read a File object and return image dimensions.
|
|
5
5
|
*/
|
|
6
|
-
function getImageDimensions(file,
|
|
6
|
+
function getImageDimensions(file, language) {
|
|
7
7
|
return new Promise((resolve, reject) => {
|
|
8
8
|
const reader = new FileReader();
|
|
9
9
|
reader.onload = (e) => {
|
|
@@ -12,18 +12,18 @@ function getImageDimensions(file, locale) {
|
|
|
12
12
|
resolve({ width: img.width, height: img.height });
|
|
13
13
|
};
|
|
14
14
|
img.onerror = () => {
|
|
15
|
-
reject(new Error(getString('unableToLoadImage',
|
|
15
|
+
reject(new Error(getString('unableToLoadImage', language)));
|
|
16
16
|
};
|
|
17
17
|
img.src = e.target?.result;
|
|
18
18
|
};
|
|
19
19
|
reader.onerror = () => {
|
|
20
|
-
reject(new Error(getString('unableToReadFile',
|
|
20
|
+
reject(new Error(getString('unableToReadFile', language)));
|
|
21
21
|
};
|
|
22
22
|
reader.readAsDataURL(file);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
export const photoFieldSchema = (field,
|
|
26
|
-
const requiredMessage = getString('requiredField',
|
|
25
|
+
export const photoFieldSchema = (field, language = 'en') => {
|
|
26
|
+
const requiredMessage = getString('requiredField', language);
|
|
27
27
|
/**
|
|
28
28
|
* Construct a custom schema for the photo field
|
|
29
29
|
*/
|
|
@@ -33,7 +33,7 @@ export const photoFieldSchema = (field, locale = 'en') => {
|
|
|
33
33
|
if (field.required) {
|
|
34
34
|
ctx.addIssue({
|
|
35
35
|
code: 'custom',
|
|
36
|
-
message: getString('noFileSelected',
|
|
36
|
+
message: getString('noFileSelected', language),
|
|
37
37
|
});
|
|
38
38
|
}
|
|
39
39
|
return; // If it's not required, do nothing (no issue).
|
|
@@ -44,7 +44,7 @@ export const photoFieldSchema = (field, locale = 'en') => {
|
|
|
44
44
|
if (!field.extensions.includes(file.name.split('.').pop())) {
|
|
45
45
|
ctx.addIssue({
|
|
46
46
|
code: 'custom',
|
|
47
|
-
message: getString('invalidImageExtension',
|
|
47
|
+
message: getString('invalidImageExtension', language, { extensions: field.extensions.join(', ') }),
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
/**
|
|
@@ -61,7 +61,7 @@ export const photoFieldSchema = (field, locale = 'en') => {
|
|
|
61
61
|
inclusive: true,
|
|
62
62
|
type: 'number',
|
|
63
63
|
origin: 'number',
|
|
64
|
-
message: getString('fileSizeExceeded',
|
|
64
|
+
message: getString('fileSizeExceeded', language, { size: field.maxFileSize.size, unit: field.maxFileSize.unit }),
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
@@ -70,7 +70,7 @@ export const photoFieldSchema = (field, locale = 'en') => {
|
|
|
70
70
|
if (!field.mimeType.includes(file.type)) {
|
|
71
71
|
ctx.addIssue({
|
|
72
72
|
code: 'custom',
|
|
73
|
-
message: getString('invalidImageType',
|
|
73
|
+
message: getString('invalidImageType', language, { types: field.mimeType.join(', ') }),
|
|
74
74
|
});
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
@@ -78,19 +78,19 @@ export const photoFieldSchema = (field, locale = 'en') => {
|
|
|
78
78
|
*/
|
|
79
79
|
if (field.size && 'strict' in field.size) {
|
|
80
80
|
try {
|
|
81
|
-
const { width, height } = await getImageDimensions(file,
|
|
81
|
+
const { width, height } = await getImageDimensions(file, language);
|
|
82
82
|
const { width: requiredW, height: requiredH } = field.size;
|
|
83
83
|
if (width !== requiredW || height !== requiredH) {
|
|
84
84
|
ctx.addIssue({
|
|
85
85
|
code: 'custom',
|
|
86
|
-
message: getString('imageDimensionMismatch',
|
|
86
|
+
message: getString('imageDimensionMismatch', language, { actual: `${width}x${height}`, required: `${requiredW}x${requiredH}` }),
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
}
|
|
90
90
|
catch (err) {
|
|
91
91
|
ctx.addIssue({
|
|
92
92
|
code: 'custom',
|
|
93
|
-
message: err.message || getString('couldNotVerifyImageDimensions',
|
|
93
|
+
message: err.message || getString('couldNotVerifyImageDimensions', language),
|
|
94
94
|
});
|
|
95
95
|
}
|
|
96
96
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { RichTextFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const richTextFieldSchema: (field: RichTextFieldClientConfig,
|
|
3
|
+
export declare const richTextFieldSchema: (field: RichTextFieldClientConfig, language?: string) => z.ZodString | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
|
|
4
4
|
//# sourceMappingURL=richText.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"richText.d.ts","sourceRoot":"","sources":["../../src/validators/richText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"richText.d.ts","sourceRoot":"","sources":["../../src/validators/richText.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,iBAAe,sFAepF,CAAA"}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const richTextFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const richTextFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const minLength = field.minLength ?? 1;
|
|
6
6
|
const maxLength = field.maxLength ?? Infinity;
|
|
7
7
|
let base = z
|
|
8
8
|
.string(requiredMessage)
|
|
9
9
|
.min(minLength, {
|
|
10
|
-
message: minLength === 1 ? requiredMessage : getString('minLength',
|
|
10
|
+
message: minLength === 1 ? requiredMessage : getString('minLength', language, { min: minLength }),
|
|
11
11
|
});
|
|
12
12
|
if (Number.isFinite(maxLength)) {
|
|
13
|
-
base = base.max(maxLength, { message: getString('maxLength',
|
|
13
|
+
base = base.max(maxLength, { message: getString('maxLength', language, { max: maxLength }) });
|
|
14
14
|
}
|
|
15
15
|
return field.required ? base : z.union([z.literal(''), base], requiredMessage).optional();
|
|
16
16
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { SelectMultipleFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const selectMultipleFieldSchema: (field: SelectMultipleFieldClientConfig,
|
|
3
|
+
export declare const selectMultipleFieldSchema: (field: SelectMultipleFieldClientConfig, language?: string) => z.ZodArray<z.ZodObject<{
|
|
4
4
|
value: z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>;
|
|
5
5
|
label: z.ZodString;
|
|
6
6
|
}, z.core.$strip>> | z.ZodOptional<z.ZodNullable<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodArray<z.ZodObject<{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select-multiple.d.ts","sourceRoot":"","sources":["../../src/validators/select-multiple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAA;AAG9E,eAAO,MAAM,yBAAyB,GAAI,OAAO,+BAA+B,EAAE,
|
|
1
|
+
{"version":3,"file":"select-multiple.d.ts","sourceRoot":"","sources":["../../src/validators/select-multiple.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAA;AAG9E,eAAO,MAAM,yBAAyB,GAAI,OAAO,+BAA+B,EAAE,iBAAe;;;;;;sBA6BhG,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const selectMultipleFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const selectMultipleFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const base = z
|
|
6
6
|
.array(z.object({
|
|
7
7
|
value: z.union([z.string(requiredMessage), z.number(requiredMessage)], requiredMessage),
|
|
@@ -14,7 +14,7 @@ export const selectMultipleFieldSchema = (field, locale = 'en') => {
|
|
|
14
14
|
if (field.required && value.length === 0) {
|
|
15
15
|
ctx.addIssue({
|
|
16
16
|
code: 'custom',
|
|
17
|
-
message: getString('atLeastOneValueRequired',
|
|
17
|
+
message: getString('atLeastOneValueRequired', language),
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
20
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { SelectFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const selectFieldSchema: (field: SelectFieldClientConfig,
|
|
3
|
+
export declare const selectFieldSchema: (field: SelectFieldClientConfig, language?: string) => z.ZodUnion<readonly [z.ZodString, z.ZodNumber]> | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodUnion<readonly [z.ZodString, z.ZodNumber]>]>>;
|
|
4
4
|
//# sourceMappingURL=select.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/validators/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAGtE,eAAO,MAAM,iBAAiB,GAAI,OAAO,uBAAuB,EAAE,
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/validators/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAA;AAGtE,eAAO,MAAM,iBAAiB,GAAI,OAAO,uBAAuB,EAAE,iBAAe,8JAWhF,CAAA"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const selectFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const selectFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const base = z.union([
|
|
6
6
|
z.string(requiredMessage).min(1, { message: requiredMessage }),
|
|
7
7
|
z.number(requiredMessage),
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { SlugFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const slugFieldSchema: (field: SlugFieldClientConfig,
|
|
3
|
+
export declare const slugFieldSchema: (field: SlugFieldClientConfig, language?: string) => z.ZodString | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
|
|
4
4
|
//# sourceMappingURL=slug.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../src/validators/slug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAUpE,eAAO,MAAM,eAAe,GAAI,OAAO,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"slug.d.ts","sourceRoot":"","sources":["../../src/validators/slug.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAUpE,eAAO,MAAM,eAAe,GAAI,OAAO,qBAAqB,EAAE,iBAAe,sFAqB5E,CAAA"}
|
package/dist/validators/slug.js
CHANGED
|
@@ -6,21 +6,21 @@ import getString from '../translations/index.js';
|
|
|
6
6
|
* Does not allow leading/trailing hyphens or consecutive hyphens.
|
|
7
7
|
*/
|
|
8
8
|
const slugPattern = /^[\p{L}\p{N}]+([-][\p{L}\p{N}]+)*$/u;
|
|
9
|
-
export const slugFieldSchema = (field,
|
|
10
|
-
const requiredMessage = getString('requiredField',
|
|
9
|
+
export const slugFieldSchema = (field, language = 'en') => {
|
|
10
|
+
const requiredMessage = getString('requiredField', language);
|
|
11
11
|
const minLength = field.minLength ?? 1;
|
|
12
12
|
const maxLength = field.maxLength ?? Infinity;
|
|
13
13
|
let base = z
|
|
14
14
|
.string(requiredMessage)
|
|
15
15
|
.trim()
|
|
16
16
|
.min(minLength, {
|
|
17
|
-
message: minLength === 1 ? requiredMessage : getString('minLength',
|
|
17
|
+
message: minLength === 1 ? requiredMessage : getString('minLength', language, { min: minLength }),
|
|
18
18
|
});
|
|
19
19
|
if (Number.isFinite(maxLength)) {
|
|
20
|
-
base = base.max(maxLength, { message: getString('maxLength',
|
|
20
|
+
base = base.max(maxLength, { message: getString('maxLength', language, { max: maxLength }) });
|
|
21
21
|
}
|
|
22
22
|
base = base.refine((val) => val === '' || slugPattern.test(val), {
|
|
23
|
-
message: getString('invalidSlugFormat',
|
|
23
|
+
message: getString('invalidSlugFormat', language),
|
|
24
24
|
});
|
|
25
25
|
return field.required ? base : z.union([z.literal(''), base], requiredMessage).optional();
|
|
26
26
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { TextFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const textFieldSchema: (field: TextFieldClientConfig,
|
|
3
|
+
export declare const textFieldSchema: (field: TextFieldClientConfig, language?: string) => z.ZodString | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
|
|
4
4
|
//# sourceMappingURL=text.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/validators/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAGpE,eAAO,MAAM,eAAe,GAAI,OAAO,qBAAqB,EAAE,
|
|
1
|
+
{"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/validators/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAA;AAGpE,eAAO,MAAM,eAAe,GAAI,OAAO,qBAAqB,EAAE,iBAAe,sFAiB5E,CAAA"}
|
package/dist/validators/text.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const textFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const textFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const minLength = field.minLength ?? 1;
|
|
6
6
|
const maxLength = field.maxLength ?? Infinity;
|
|
7
7
|
let base = z
|
|
8
8
|
.string(requiredMessage)
|
|
9
9
|
.trim()
|
|
10
10
|
.min(minLength, {
|
|
11
|
-
message: minLength === 1 ? requiredMessage : getString('minLength',
|
|
11
|
+
message: minLength === 1 ? requiredMessage : getString('minLength', language, { min: minLength }),
|
|
12
12
|
});
|
|
13
13
|
if (Number.isFinite(maxLength)) {
|
|
14
|
-
base = base.max(maxLength, { message: getString('maxLength',
|
|
14
|
+
base = base.max(maxLength, { message: getString('maxLength', language, { max: maxLength }) });
|
|
15
15
|
}
|
|
16
16
|
return field.required ? base : z.union([z.literal(''), base], requiredMessage).optional();
|
|
17
17
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { TextAreaFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const textareaFieldSchema: (field: TextAreaFieldClientConfig,
|
|
3
|
+
export declare const textareaFieldSchema: (field: TextAreaFieldClientConfig, language?: string) => z.ZodString | z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"">, z.ZodString]>>;
|
|
4
4
|
//# sourceMappingURL=textarea.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/validators/textarea.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,
|
|
1
|
+
{"version":3,"file":"textarea.d.ts","sourceRoot":"","sources":["../../src/validators/textarea.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AAGxE,eAAO,MAAM,mBAAmB,GAAI,OAAO,yBAAyB,EAAE,iBAAe,sFAiBpF,CAAA"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const textareaFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const textareaFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
const minLength = field.minLength ?? 1;
|
|
6
6
|
const maxLength = field.maxLength ?? Infinity;
|
|
7
7
|
let base = z
|
|
8
8
|
.string(requiredMessage)
|
|
9
9
|
.trim()
|
|
10
10
|
.min(minLength, {
|
|
11
|
-
message: minLength === 1 ? requiredMessage : getString('minLength',
|
|
11
|
+
message: minLength === 1 ? requiredMessage : getString('minLength', language, { min: minLength }),
|
|
12
12
|
});
|
|
13
13
|
if (Number.isFinite(maxLength)) {
|
|
14
|
-
base = base.max(maxLength, { message: getString('maxLength',
|
|
14
|
+
base = base.max(maxLength, { message: getString('maxLength', language, { max: maxLength }) });
|
|
15
15
|
}
|
|
16
16
|
return field.required ? base : z.union([z.literal(''), base], requiredMessage).optional();
|
|
17
17
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import type { VideoFieldClientConfig } from '../core/fields/index.js';
|
|
3
|
-
export declare const videoFieldSchema: (field: VideoFieldClientConfig,
|
|
3
|
+
export declare const videoFieldSchema: (field: VideoFieldClientConfig, language?: string) => z.ZodCustom<File, File> | z.ZodOptional<z.ZodUnion<readonly [z.ZodNull, z.ZodUndefined, z.ZodCustom<File, File>]>>;
|
|
4
4
|
//# sourceMappingURL=video.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../src/validators/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAGrE,eAAO,MAAM,gBAAgB,GAAI,OAAO,sBAAsB,EAAE,
|
|
1
|
+
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../src/validators/video.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,KAAK,CAAA;AACxB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAGrE,eAAO,MAAM,gBAAgB,GAAI,OAAO,sBAAsB,EAAE,iBAAe,uHA6D9E,CAAA"}
|
package/dist/validators/video.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod';
|
|
2
2
|
import getString from '../translations/index.js';
|
|
3
|
-
export const videoFieldSchema = (field,
|
|
4
|
-
const requiredMessage = getString('requiredField',
|
|
3
|
+
export const videoFieldSchema = (field, language = 'en') => {
|
|
4
|
+
const requiredMessage = getString('requiredField', language);
|
|
5
5
|
/**
|
|
6
6
|
* Construct a custom schema for the video field
|
|
7
7
|
*/
|
|
@@ -11,7 +11,7 @@ export const videoFieldSchema = (field, locale = 'en') => {
|
|
|
11
11
|
if (field.required) {
|
|
12
12
|
ctx.addIssue({
|
|
13
13
|
code: 'custom',
|
|
14
|
-
message: getString('noFileSelected',
|
|
14
|
+
message: getString('noFileSelected', language),
|
|
15
15
|
});
|
|
16
16
|
}
|
|
17
17
|
return; // If it's not required, do nothing (no issue).
|
|
@@ -22,7 +22,7 @@ export const videoFieldSchema = (field, locale = 'en') => {
|
|
|
22
22
|
if (!field.extensions.includes(file.name.split('.').pop())) {
|
|
23
23
|
ctx.addIssue({
|
|
24
24
|
code: 'custom',
|
|
25
|
-
message: getString('invalidFileExtension',
|
|
25
|
+
message: getString('invalidFileExtension', language, { extensions: field.extensions.join(', ') }),
|
|
26
26
|
});
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
@@ -39,7 +39,7 @@ export const videoFieldSchema = (field, locale = 'en') => {
|
|
|
39
39
|
inclusive: true,
|
|
40
40
|
type: 'number',
|
|
41
41
|
origin: 'number',
|
|
42
|
-
message: getString('fileSizeExceeded',
|
|
42
|
+
message: getString('fileSizeExceeded', language, { size: field.maxFileSize.size, unit: field.maxFileSize.unit }),
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
45
|
/**
|
|
@@ -48,7 +48,7 @@ export const videoFieldSchema = (field, locale = 'en') => {
|
|
|
48
48
|
if (!field.mimeType.includes(file.type)) {
|
|
49
49
|
ctx.addIssue({
|
|
50
50
|
code: 'custom',
|
|
51
|
-
message: getString('invalidVideoType',
|
|
51
|
+
message: getString('invalidVideoType', language, { types: field.mimeType.join(', ') }),
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
54
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nextjs-cms",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.3",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
@@ -206,8 +206,8 @@
|
|
|
206
206
|
"tsx": "^4.20.6",
|
|
207
207
|
"typescript": "^5.9.2",
|
|
208
208
|
"@lzcms/eslint-config": "0.3.0",
|
|
209
|
-
"@lzcms/
|
|
210
|
-
"@lzcms/
|
|
209
|
+
"@lzcms/tsconfig": "0.1.0",
|
|
210
|
+
"@lzcms/prettier-config": "0.1.0"
|
|
211
211
|
},
|
|
212
212
|
"license": "MIT",
|
|
213
213
|
"keywords": [
|