a15884ea0a
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
16 lines
376 B
TypeScript
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);
|
|
}
|
|
}
|