Skip to content

Commit ce75dd1

Browse files
committed
change key/value restriction
1 parent d5ff9c6 commit ce75dd1

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/common/types/events.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { z } from "zod";
22

33
export const MAX_METADATA_KEYS = 10;
4-
export const MAX_STRING_LENGTH = 100;
4+
export const MAX_KEY_LENGTH = 50;
5+
export const MAX_VALUE_LENGTH = 1000;
56

67
export const metadataSchema = z
78
.record(z.string())
@@ -19,18 +20,18 @@ export const metadataSchema = z
1920
}
2021

2122
for (const key of keys) {
22-
if (key.length > MAX_STRING_LENGTH) {
23+
if (key.length > MAX_KEY_LENGTH) {
2324
ctx.addIssue({
2425
code: z.ZodIssueCode.custom,
25-
message: `Metadata key "${key}" exceeds ${MAX_STRING_LENGTH} characters.`,
26+
message: `Metadata key "${key}" exceeds ${MAX_KEY_LENGTH} characters.`,
2627
});
2728
}
2829

2930
const value = metadata[key];
30-
if (value.length > MAX_STRING_LENGTH) {
31+
if (value.length > MAX_VALUE_LENGTH) {
3132
ctx.addIssue({
3233
code: z.ZodIssueCode.custom,
33-
message: `Metadata value for key "${key}" exceeds ${MAX_STRING_LENGTH} characters.`,
34+
message: `Metadata value for key "${key}" exceeds ${MAX_VALUE_LENGTH} characters.`,
3435
});
3536
}
3637
}

src/ui/pages/events/ManageEvent.page.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,12 @@ import { OrganizationList as orgList } from '@common/orgs';
2424
import { AppRoles } from '@common/roles';
2525
import { EVENT_CACHED_DURATION } from '@common/config';
2626
import { IconPlus, IconTrash } from '@tabler/icons-react';
27-
import { MAX_METADATA_KEYS, MAX_STRING_LENGTH, metadataSchema } from '@common/types/events';
27+
import {
28+
MAX_METADATA_KEYS,
29+
MAX_KEY_LENGTH,
30+
MAX_VALUE_LENGTH,
31+
metadataSchema,
32+
} from '@common/types/events';
2833

2934
export function capitalizeFirstLetter(string: string) {
3035
return string.charAt(0).toUpperCase() + string.slice(1);
@@ -348,8 +353,8 @@ export const ManageEventPage: React.FC = () => {
348353
</Button>
349354
</Group>
350355
<Text size="xs" c="dimmed">
351-
These values can be acceessed via the API. Max {MAX_STRING_LENGTH} characters for keys
352-
and values.
356+
These values can be acceessed via the API. Max {MAX_KEY_LENGTH} characters for keys
357+
and {MAX_VALUE_LENGTH} chars for values.
353358
</Text>
354359

355360
{Object.entries(form.values.metadata || {}).map(([key, value], index) => {

0 commit comments

Comments
 (0)