Update user friendly errors for translations (#15000)
Force msg typing instead of string for user friendly errors
This commit is contained in:
+7
-7
@@ -53,7 +53,7 @@ const validateMetadataOptionLabel = (
|
||||
{
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: t`Option label is required`,
|
||||
userFriendlyMessage: t`Option label is required`,
|
||||
userFriendlyMessage: msg`Option label is required`,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -63,7 +63,7 @@ const validateMetadataOptionLabel = (
|
||||
{
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: t`Option label must be a string of at least one character`,
|
||||
userFriendlyMessage: t`Option label format not supported`,
|
||||
userFriendlyMessage: msg`Option label format not supported`,
|
||||
value: sanitizedLabel,
|
||||
},
|
||||
];
|
||||
@@ -102,7 +102,7 @@ const validateMetadataOptionValue = (
|
||||
{
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: t`Option value is required`,
|
||||
userFriendlyMessage: t`Option value is required`,
|
||||
userFriendlyMessage: msg`Option value is required`,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -112,7 +112,7 @@ const validateMetadataOptionValue = (
|
||||
{
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: t`Option value must be a string of at least one character`,
|
||||
userFriendlyMessage: t`Option value format not supported`,
|
||||
userFriendlyMessage: msg`Option value format not supported`,
|
||||
},
|
||||
];
|
||||
}
|
||||
@@ -175,7 +175,7 @@ const validateFieldMetadataInputOptions = <T extends EnumFieldMetadataType>(
|
||||
{
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: 'Options are required for enum fields',
|
||||
userFriendlyMessage: t`Options are required for enum fields`,
|
||||
userFriendlyMessage: msg`Options are required for enum fields`,
|
||||
value: options,
|
||||
},
|
||||
];
|
||||
@@ -206,7 +206,7 @@ const validateSelectDefaultValue = ({
|
||||
{
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: `Default value for select must be a string got ${defaultValue}`,
|
||||
userFriendlyMessage: t`Default value must be a string`,
|
||||
userFriendlyMessage: msg`Default value must be a string`,
|
||||
value: defaultValue,
|
||||
},
|
||||
];
|
||||
@@ -243,7 +243,7 @@ const validateMultiSelectDefaultValue = ({
|
||||
return [
|
||||
{
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
userFriendlyMessage: t`Multi-select field default value must be an array`,
|
||||
userFriendlyMessage: msg`Multi-select field default value must be an array`,
|
||||
message: `Default value for multi-select must be an array got ${multiSelectDefaultValue}`,
|
||||
value: multiSelectDefaultValue,
|
||||
},
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { FieldMetadataType } from 'twenty-shared/types';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
|
||||
@@ -101,7 +101,7 @@ export const validateFlatFieldMetadataNameAvailability = ({
|
||||
code: FieldMetadataExceptionCode.NOT_AVAILABLE,
|
||||
value: flatFieldMetadataName,
|
||||
message: `Name "${flatFieldMetadataName}" is not available as it is already used by another field`,
|
||||
userFriendlyMessage: t`Name "${flatFieldMetadataName}" is not available as it is already used by another field`,
|
||||
userFriendlyMessage: msg`Name "${flatFieldMetadataName}" is not available as it is already used by another field`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ export const validateFlatFieldMetadataNameAvailability = ({
|
||||
code: FieldMetadataExceptionCode.RESERVED_KEYWORD,
|
||||
message: `Name "${flatFieldMetadataName}" is reserved composite field name`,
|
||||
value: flatFieldMetadataName,
|
||||
userFriendlyMessage: t`Name "${flatFieldMetadataName}" is not available`,
|
||||
userFriendlyMessage: msg`Name "${flatFieldMetadataName}" is not available`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+2
-4
@@ -1,5 +1,3 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
|
||||
import { FieldMetadataExceptionCode } from 'src/engine/metadata-modules/field-metadata/field-metadata.exception';
|
||||
import { type FlatFieldMetadataValidationError } from 'src/engine/metadata-modules/flat-field-metadata/types/flat-field-metadata-validation-error.type';
|
||||
import { METADATA_NAME_VALIDATORS } from 'src/engine/metadata-modules/utils/constants/metadata-name-flat-metadata-validators.constants';
|
||||
@@ -13,8 +11,8 @@ export const validateFlatFieldMetadataName = (
|
||||
if (isInvalid) {
|
||||
return {
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: t(message),
|
||||
userFriendlyMessage: t(message),
|
||||
message: message.message ?? '',
|
||||
userFriendlyMessage: message,
|
||||
value: name,
|
||||
};
|
||||
}
|
||||
|
||||
+4
-4
@@ -1,4 +1,4 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { isDefined, isValidUuid } from 'twenty-shared/utils';
|
||||
|
||||
import { FieldMetadataExceptionCode } from 'src/engine/metadata-modules/field-metadata/field-metadata.exception';
|
||||
@@ -26,7 +26,7 @@ export const validateMorphOrRelationFlatFieldMetadata = async ({
|
||||
: {
|
||||
code: FieldMetadataExceptionCode.INVALID_FIELD_INPUT,
|
||||
message: `Invalid uuid ${id}`,
|
||||
userFriendlyMessage: t`Invalid uuid ${id}`,
|
||||
userFriendlyMessage: msg`Invalid uuid ${id}`,
|
||||
value: id,
|
||||
},
|
||||
);
|
||||
@@ -44,7 +44,7 @@ export const validateMorphOrRelationFlatFieldMetadata = async ({
|
||||
errors.push({
|
||||
code: FieldMetadataExceptionCode.OBJECT_METADATA_NOT_FOUND,
|
||||
message: 'Relation target object metadata not found',
|
||||
userFriendlyMessage: t`Object targeted by the relation not found`,
|
||||
userFriendlyMessage: msg`Object targeted by the relation not found`,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -61,7 +61,7 @@ export const validateMorphOrRelationFlatFieldMetadata = async ({
|
||||
message: isDefined(remainingFlatEntityMapsToValidate)
|
||||
? 'Relation field target metadata not found in both existing and about to be created field metadatas'
|
||||
: 'Relation field target metadata not found',
|
||||
userFriendlyMessage: t`Relation field target metadata not found`,
|
||||
userFriendlyMessage: msg`Relation field target metadata not found`,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+6
-6
@@ -1,4 +1,4 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { isDefined } from 'class-validator';
|
||||
import { type RelationCreationPayload } from 'twenty-shared/types';
|
||||
|
||||
@@ -35,7 +35,7 @@ export const validateMorphRelationCreationPayload = async ({
|
||||
error: {
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message: 'Morph relation creation payloads are empty',
|
||||
userFriendlyMessage: t`At least one relation is require`,
|
||||
userFriendlyMessage: msg`At least one relation is require`,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -55,7 +55,7 @@ export const validateMorphRelationCreationPayload = async ({
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message:
|
||||
'Morph relation creation payloads must have the same relation type',
|
||||
userFriendlyMessage: t`Morph relation creation payloads must have the same relation type`,
|
||||
userFriendlyMessage: msg`Morph relation creation payloads must have the same relation type`,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -74,7 +74,7 @@ export const validateMorphRelationCreationPayload = async ({
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message:
|
||||
'Morph relation creation payloads must not target source object metadata',
|
||||
userFriendlyMessage: t`Morph relation creation payloads must only contain relation to other object metadata`,
|
||||
userFriendlyMessage: msg`Morph relation creation payloads must only contain relation to other object metadata`,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export const validateMorphRelationCreationPayload = async ({
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message:
|
||||
'Morph relation creation payloads must have only relation to the same object metadata',
|
||||
userFriendlyMessage: t`Morph relation creation payloads must only contain relation to the same object metadata`,
|
||||
userFriendlyMessage: msg`Morph relation creation payloads must only contain relation to the same object metadata`,
|
||||
},
|
||||
};
|
||||
}
|
||||
@@ -130,7 +130,7 @@ export const validateMorphRelationCreationPayload = async ({
|
||||
error: {
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message: 'Morph relation input transpilation failed',
|
||||
userFriendlyMessage: t`Invalid morph relation input`,
|
||||
userFriendlyMessage: msg`Invalid morph relation input`,
|
||||
value: relationCreationPayloadReport.failed
|
||||
.map((failedTranspilation) => failedTranspilation.error.value)
|
||||
.filter(isDefined),
|
||||
|
||||
+3
-3
@@ -1,4 +1,4 @@
|
||||
import { t } from '@lingui/core/macro';
|
||||
import { msg } from '@lingui/core/macro';
|
||||
import { type RelationCreationPayload } from 'twenty-shared/types';
|
||||
import {
|
||||
isDefined,
|
||||
@@ -42,7 +42,7 @@ export const validateRelationCreationPayload = async ({
|
||||
error: {
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message: `Relation creation payload is invalid`,
|
||||
userFriendlyMessage: t`Invalid relation creation payload`,
|
||||
userFriendlyMessage: msg`Invalid relation creation payload`,
|
||||
value: relationCreationPayload,
|
||||
},
|
||||
};
|
||||
@@ -62,7 +62,7 @@ export const validateRelationCreationPayload = async ({
|
||||
error: {
|
||||
code: FieldMetadataExceptionCode.FIELD_METADATA_RELATION_MALFORMED,
|
||||
message: `Object metadata relation target not found for relation creation payload`,
|
||||
userFriendlyMessage: t`Object targeted by field to create not found`,
|
||||
userFriendlyMessage: msg`Object targeted by field to create not found`,
|
||||
value: relationCreationPayload,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user