[BUGFIX] ObjectMetadata item server validation (#10699)
# Introduction This PR contains several SNAPSHOT files explaining big + While refactoring the Object Model settings page in https://github.com/twentyhq/twenty/pull/10653, encountered a critical issue when submitting either one or both names with `""` empty string hard corrupting a workspace. This motivate this PR reviewing server side validation I feel like we could share zod schema between front and back ## Refactored server validation What to expect from Names: - Plural and singular have to be different ( case insensitive and trimmed check ) - Contains only a-z A-Z and 0-9 - Follows camelCase - Is not empty => Is not too short ( 1 ) - Is not too long ( 63 ) - Is case insensitive( fooBar and fOoBar now rejected ) What to expect from Labels: - Plural and singular have to be different ( case insensitive and trimmed check ) - Is not empty => Is not too short ( 1 ) - Is not too long ( 63 ) - Is case insensitive ( fooBar and fOoBar now rejected ) close https://github.com/twentyhq/twenty/issues/10694 ## Creation integrations tests Created new integrations tests, following [EachTesting](https://jestjs.io/docs/api#testeachtablename-fn-timeout) pattern and uses snapshot to assert errors message. These tests cover several failing use cases and started to implement ones for the happy path but object metadata item deletion is currently broken unless I'm mistaken @Weiko is on it ## Notes - [ ] As we've added new validation rules towards names and labels we should scan db in order to standardize existing values using either a migration command or manual check - [ ] Will review in an other PR the update path, adding integrations tests and so on
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
export * from './constants';
|
||||
export * from './i18n';
|
||||
export * from './testing';
|
||||
export * from './types';
|
||||
export * from './utils';
|
||||
export * from './workspace';
|
||||
|
||||
1
packages/twenty-shared/src/testing/index.ts
Normal file
1
packages/twenty-shared/src/testing/index.ts
Normal file
@ -0,0 +1 @@
|
||||
export * from './types/EachTestingContext.type';
|
||||
@ -0,0 +1,4 @@
|
||||
export type EachTestingContext<T> = {
|
||||
title: string;
|
||||
context: T;
|
||||
};
|
||||
@ -1,4 +1,3 @@
|
||||
export * from './ConnectedAccountProvider';
|
||||
export * from './FieldMetadataType';
|
||||
export * from './IsExactly';
|
||||
|
||||
|
||||
@ -4,4 +4,3 @@ export * from './image';
|
||||
export * from './strings';
|
||||
export * from './url';
|
||||
export * from './validation';
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { APP_LOCALES } from 'src/i18n/constants/AppLocales';
|
||||
import { isValidLocale } from '../isValidLocale';
|
||||
import { APP_LOCALES } from 'src/constants/Locales';
|
||||
|
||||
describe('isValidLocale', () => {
|
||||
it('should return true for valid locales', () => {
|
||||
|
||||
Reference in New Issue
Block a user