1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-09 23:17:29 +02:00

fix(server): avoid server error for invalid email data type (#10978)

* fix(server): avoid server error for invalid email data type

* add e2e test

* fix e2e
This commit is contained in:
Michel Heusschen
2024-07-10 13:58:06 +02:00
committed by GitHub
parent 27b13b82f5
commit bd88b079ea
5 changed files with 36 additions and 4 deletions

View File

@@ -152,11 +152,14 @@ export function validateCronExpression(expression: string) {
return true;
}
type IValue = { value: string };
type IValue = { value: unknown };
export const toEmail = ({ value }: IValue) => (value ? value.toLowerCase() : value);
export const toEmail = ({ value }: IValue) => (typeof value === 'string' ? value.toLowerCase() : value);
export const toSanitized = ({ value }: IValue) => sanitize((value || '').replaceAll('.', ''));
export const toSanitized = ({ value }: IValue) => {
const input = typeof value === 'string' ? value : '';
return sanitize(input.replaceAll('.', ''));
};
export const isValidInteger = (value: number, options: { min?: number; max?: number }): value is number => {
const { min = Number.MIN_SAFE_INTEGER, max = Number.MAX_SAFE_INTEGER } = options;