mirror of
https://github.com/immich-app/immich
synced 2026-08-22 13:13:05 +00:00
fix: automatically remove leading/trailing whitespace from search que… (#22214)
fix: automatically remove leading/trailing whitespace from search queries
This commit is contained in:
parent
3f2e0780d5
commit
6da039780e
2 changed files with 17 additions and 13 deletions
|
|
@ -211,6 +211,18 @@ export const ValidateDate = (options?: DateOptions & ApiPropertyOptions) => {
|
|||
return applyDecorators(...decorators);
|
||||
};
|
||||
|
||||
type StringOptions = { optional?: boolean; nullable?: boolean; trim?: boolean };
|
||||
export const ValidateString = (options?: StringOptions & ApiPropertyOptions) => {
|
||||
const { optional, nullable, trim, ...apiPropertyOptions } = options || {};
|
||||
const decorators = [ApiProperty(apiPropertyOptions), IsString(), optional ? Optional({ nullable }) : IsNotEmpty()];
|
||||
|
||||
if (trim) {
|
||||
decorators.push(Transform(({ value }: { value: string }) => value?.trim()));
|
||||
}
|
||||
|
||||
return applyDecorators(...decorators);
|
||||
};
|
||||
|
||||
type BooleanOptions = { optional?: boolean; nullable?: boolean };
|
||||
export const ValidateBoolean = (options?: BooleanOptions & ApiPropertyOptions) => {
|
||||
const { optional, nullable, ...apiPropertyOptions } = options || {};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue