17
front/src/modules/metadata/utils/formatMetadataFieldInput.ts
Normal file
17
front/src/modules/metadata/utils/formatMetadataFieldInput.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import toCamelCase from 'lodash.camelcase';
|
||||
import upperFirst from 'lodash.upperfirst';
|
||||
|
||||
import { ObjectFieldDataType } from '@/settings/data-model/types/ObjectFieldDataType';
|
||||
import { Field } from '~/generated-metadata/graphql';
|
||||
|
||||
export const formatMetadataFieldInput = (
|
||||
input: Pick<Field, 'label' | 'icon' | 'description'> & {
|
||||
type: ObjectFieldDataType;
|
||||
},
|
||||
) => ({
|
||||
description: input.description?.trim() ?? null,
|
||||
icon: input.icon,
|
||||
label: input.label.trim(),
|
||||
name: upperFirst(toCamelCase(input.label.trim())),
|
||||
type: input.type,
|
||||
});
|
||||
@ -0,0 +1,4 @@
|
||||
const metadataLabelValidationPattern = /^[a-zA-Z][a-zA-Z0-9 ]*$/;
|
||||
|
||||
export const validateMetadataLabel = (value: string) =>
|
||||
!!value.match(metadataLabelValidationPattern);
|
||||
@ -1,4 +0,0 @@
|
||||
const metadataObjectLabelValidationPattern = /^[a-zA-Z][a-zA-Z0-9 ]*$/;
|
||||
|
||||
export const validateMetadataObjectLabel = (value: string) =>
|
||||
!!value.match(metadataObjectLabelValidationPattern);
|
||||
Reference in New Issue
Block a user