mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-17 21:15:32 +09:00
fix(AdminUserSchemas): use DiscriminatorType for discriminator (#1218)
Co-authored-by: Hampus <[email protected]>
This commit is contained in:
1 parent
4a741d8396
commit
4a93082f0a
10 files changed
+38
-20
No files matched your search
@@ -18,7 +18,7 @@ import {
|
||||
SnowflakeStringType,
|
||||
SnowflakeType,
|
||||
} from '@fluxer/schema/src/primitives/SchemaPrimitives';
|
||||
import {EmailType, UsernameType} from '@fluxer/schema/src/primitives/UserValidators';
|
||||
import {DiscriminatorType, EmailType, UsernameType} from '@fluxer/schema/src/primitives/UserValidators';
|
||||
import {z} from 'zod';
|
||||
|
||||
export const UserAdminResponseSchema = z.object({
|
||||
@@ -302,7 +302,7 @@ export type SendPasswordResetRequest = z.infer<typeof SendPasswordResetRequest>;
|
||||
export const ChangeUsernameRequest = z.object({
|
||||
user_id: SnowflakeType.describe('ID of the user to change username for'),
|
||||
username: UsernameType.describe('New username for the user'),
|
||||
discriminator: Int32Type.optional().describe('Legacy discriminator value'),
|
||||
discriminator: DiscriminatorType.optional().describe('Legacy discriminator value'),
|
||||
});
|
||||
|
||||
export type ChangeUsernameRequest = z.infer<typeof ChangeUsernameRequest>;
|
||||
|
||||
@@ -50,13 +50,16 @@ export const EmailType = withOpenApiType(
|
||||
}, ValidationErrorCodes.INVALID_EMAIL_LOCAL_PART),
|
||||
'EmailType',
|
||||
);
|
||||
export const DiscriminatorType = z
|
||||
.union([z.string(), z.number()])
|
||||
.transform((value) => String(value))
|
||||
.pipe(z.string().regex(DISCRIMINATOR_REGEX, ValidationErrorCodes.DISCRIMINATOR_INVALID_FORMAT))
|
||||
.transform((value) => {
|
||||
return Number.parseInt(value, 10);
|
||||
});
|
||||
export const DiscriminatorType = withOpenApiType(
|
||||
z
|
||||
.union([z.string(), z.number()])
|
||||
.transform((value) => String(value))
|
||||
.pipe(z.string().regex(DISCRIMINATOR_REGEX, ValidationErrorCodes.DISCRIMINATOR_INVALID_FORMAT))
|
||||
.transform((value) => {
|
||||
return Number.parseInt(value, 10);
|
||||
}),
|
||||
'DiscriminatorType',
|
||||
);
|
||||
export const UsernameType = withOpenApiType(
|
||||
z
|
||||
.string()
|
||||
|
||||
Reference in new issue
Block a user