Skip to content

Commit 7a453ea

Browse files
committed
refactor(core): use config jsonb type
1 parent 1abe402 commit 7a453ea

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

packages/core/src/libraries/custom-profile-fields.ts

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,44 +60,48 @@ export const createCustomProfileFieldsLibrary = (queries: Queries) => {
6060
const validateCustomProfileField = (data: CreateCustomProfileFieldData) => {
6161
switch (data.type) {
6262
case CustomProfileFieldType.Text: {
63-
const { minLength, maxLength } = textProfileFieldGuard.parse(data);
63+
const {
64+
config: { minLength, maxLength },
65+
} = textProfileFieldGuard.parse(data);
6466
assertThat(
6567
minLength && maxLength && minLength <= maxLength,
6668
'custom_profile_fields.invalid_min_max_input'
6769
);
6870
break;
6971
}
7072
case CustomProfileFieldType.Number: {
71-
const { minValue, maxValue } = numberProfileFieldGuard.parse(data);
73+
const {
74+
config: { minValue, maxValue },
75+
} = numberProfileFieldGuard.parse(data);
7276
assertThat(
7377
minValue && maxValue && minValue <= maxValue,
7478
'custom_profile_fields.invalid_min_max_input'
7579
);
7680
break;
7781
}
7882
case CustomProfileFieldType.Checkbox: {
79-
const { options } = checkboxProfileFieldGuard.parse(data);
80-
assertThat(options.length > 0, 'custom_profile_fields.invalid_options');
83+
const { config } = checkboxProfileFieldGuard.parse(data);
84+
assertThat(config.options.length > 0, 'custom_profile_fields.invalid_options');
8185
break;
8286
}
8387
case CustomProfileFieldType.Select: {
84-
const { options } = selectProfileFieldGuard.parse(data);
85-
assertThat(options.length > 0, 'custom_profile_fields.invalid_options');
88+
const { config } = selectProfileFieldGuard.parse(data);
89+
assertThat(config.options.length > 0, 'custom_profile_fields.invalid_options');
8690
break;
8791
}
8892
case CustomProfileFieldType.Regex: {
89-
const { format } = regexProfileFieldGuard.parse(data);
90-
assertThat(isValidRegEx(format), 'custom_profile_fields.invalid_regex_format');
93+
const { config } = regexProfileFieldGuard.parse(data);
94+
assertThat(isValidRegEx(config.format), 'custom_profile_fields.invalid_regex_format');
9195
break;
9296
}
9397
case CustomProfileFieldType.Address: {
94-
const { parts } = addressProfileFieldGuard.parse(data);
95-
assertThat(parts.length > 0, 'custom_profile_fields.invalid_address_parts');
98+
const { config } = addressProfileFieldGuard.parse(data);
99+
assertThat(config.parts.length > 0, 'custom_profile_fields.invalid_address_parts');
96100
break;
97101
}
98102
case CustomProfileFieldType.Fullname: {
99-
const { parts } = fullnameProfileFieldGuard.parse(data);
100-
assertThat(parts.length > 0, 'custom_profile_fields.invalid_fullname_parts');
103+
const { config } = fullnameProfileFieldGuard.parse(data);
104+
assertThat(config.parts.length > 0, 'custom_profile_fields.invalid_fullname_parts');
101105
break;
102106
}
103107
case CustomProfileFieldType.Url: {

0 commit comments

Comments
 (0)