mirror of
https://github.com/immich-app/immich
synced 2025-11-07 17:27:20 +00:00
feat: user pin-code (#18138)
* feat: user pincode * pr feedback * chore: cleanup --------- Co-authored-by: Jason Rasmussen <jason@rasm.me>
This commit is contained in:
parent
55af925ab3
commit
3f719bd8d7
28 changed files with 1392 additions and 39 deletions
|
|
@ -18,6 +18,7 @@ import {
|
|||
IsOptional,
|
||||
IsString,
|
||||
IsUUID,
|
||||
Matches,
|
||||
Validate,
|
||||
ValidateBy,
|
||||
ValidateIf,
|
||||
|
|
@ -70,6 +71,22 @@ export class UUIDParamDto {
|
|||
id!: string;
|
||||
}
|
||||
|
||||
type PinCodeOptions = { optional?: boolean } & OptionalOptions;
|
||||
export const PinCode = ({ optional, ...options }: PinCodeOptions = {}) => {
|
||||
const decorators = [
|
||||
IsString(),
|
||||
IsNotEmpty(),
|
||||
Matches(/^\d{6}$/, { message: ({ property }) => `${property} must be a 6-digit numeric string` }),
|
||||
ApiProperty({ example: '123456' }),
|
||||
];
|
||||
|
||||
if (optional) {
|
||||
decorators.push(Optional(options));
|
||||
}
|
||||
|
||||
return applyDecorators(...decorators);
|
||||
};
|
||||
|
||||
export interface OptionalOptions extends ValidationOptions {
|
||||
nullable?: boolean;
|
||||
/** convert empty strings to null */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue