Files
twenty/packages/twenty-server/src/engine/metadata-modules/utils/validate-metadata-name.utils.ts
T
Thomas Trompette a15884ea0a Add exceptions for metadata modules (#6070)
Class exception for each metadata module + handler to map on graphql
error

TODO left :
- find a way to call handler on auto-resolvers nestjs query (probably
interceptors)
- discuss what should be done for pre-hooks errors
- discuss what should be done for Unauthorized exception
2024-07-01 13:49:17 +02:00

16 lines
376 B
TypeScript

const VALID_STRING_PATTERN = /^[a-z][a-zA-Z0-9]*$/;
export const validateMetadataName = (string: string) => {
if (!string.match(VALID_STRING_PATTERN)) {
throw new InvalidStringException(string);
}
};
export class InvalidStringException extends Error {
constructor(string: string) {
const message = `String "${string}" is not valid`;
super(message);
}
}