Ensure stored client metadata values respect constraints
This commit is contained in:
@@ -8,13 +8,13 @@
|
||||
|
||||
import { MetaType } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { AllowedMetadataValueTypes, AppMetadataKeys, Metadata } from '@/modules/metadata/Metadata.types.ts';
|
||||
import { APP_METADATA_KEY_TO_TYPE } from '@/modules/metadata/Metadata.constants.ts';
|
||||
import { APP_METADATA } from '@/modules/metadata/Metadata.constants.ts';
|
||||
|
||||
export const convertValueFromMetadata = <T extends AllowedMetadataValueTypes = AllowedMetadataValueTypes>(
|
||||
key: string,
|
||||
value: string,
|
||||
): T => {
|
||||
const typeOfKey = APP_METADATA_KEY_TO_TYPE[key as AppMetadataKeys];
|
||||
const typeOfKey = APP_METADATA[key as AppMetadataKeys].type;
|
||||
const isAutoType = typeOfKey === 'auto';
|
||||
|
||||
if ((isAutoType && !Number.isNaN(+value)) || typeOfKey === 'number') {
|
||||
|
||||
Reference in New Issue
Block a user