Files
twenty_crm/packages/twenty-server/src/engine/metadata-modules/remote-server/utils/validate-remote-server-input.ts
Thomas Trompette 1c6f0eb577 Integrate relations for remote objects (#4754)
Foreign table id cannot be a foreign key of a base table. But the
current code use foreign keys to link object metadata with activities,
events... So we will:
- create a column without creating a foreign key
- add a comment on the table schema so pg_graphql sees it as a foreign
key

This PR:
- refactor a bit object metadata service so the mutation creation is
separated into an util
- adds the mutation creation for remote object relations
- add a new type of mutation to create a comment

---------

Co-authored-by: Thomas Trompette <thomast@twenty.com>
2024-04-03 14:56:51 +02:00

21 lines
528 B
TypeScript

const INPUT_REGEX = /^([A-Za-z0-9\-\_\.]+)$/;
export const validateObject = (input: object) => {
for (const [key, value] of Object.entries(input)) {
// Password are encrypted so we don't need to validate them
if (key === 'password') {
continue;
}
if (!INPUT_REGEX.test(value.toString())) {
throw new Error('Invalid remote server input');
}
}
};
export const validateString = (input: string) => {
if (!INPUT_REGEX.test(input)) {
throw new Error('Invalid remote server input');
}
};