Add endpoints to create and delete remote server (#4606)
* Build remote server * Add getters * Migrate to json inputs * Use extendable type * Use regex validation * Remove acronymes --------- Co-authored-by: Thomas Trompette <thomast@twenty.com>
This commit is contained in:
@ -0,0 +1,20 @@
|
||||
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');
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user