mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 12:55:00 +00:00
chore(server): validate function not actually used (#11263)
This commit is contained in:
@@ -37,7 +37,7 @@ export type ConfigDescriptor<T> = {
|
||||
type ConfigDefineDescriptor<T> = {
|
||||
desc: string;
|
||||
default: T;
|
||||
validate?: (value: T) => boolean;
|
||||
validate?: (value: T) => z.SafeParseReturnType<T, T>;
|
||||
shape?: z.ZodType<T>;
|
||||
env?: string | [string, EnvConfigType];
|
||||
link?: string;
|
||||
@@ -158,7 +158,7 @@ function standardizeDescriptor<T>(
|
||||
default: desc.default,
|
||||
type,
|
||||
validate: (value: T) => {
|
||||
return shape.safeParse(value);
|
||||
return desc.validate ? desc.validate(value) : shape.safeParse(value);
|
||||
},
|
||||
env,
|
||||
link: desc.link,
|
||||
@@ -257,7 +257,15 @@ export function getDefaultConfig(): AppConfigSchema {
|
||||
const { success, error } = desc.validate(defaultValue);
|
||||
|
||||
if (!success) {
|
||||
throw error;
|
||||
throw new Error(
|
||||
error.issues
|
||||
.map(issue => {
|
||||
return `Invalid config for module [${module}] with key [${key}]
|
||||
Value: ${JSON.stringify(defaultValue)}
|
||||
Error: ${issue.message}`;
|
||||
})
|
||||
.join('\n')
|
||||
);
|
||||
}
|
||||
|
||||
set(modulizedConfig, key, defaultValue);
|
||||
|
||||
@@ -23,7 +23,7 @@ defineModuleConfig('redis', {
|
||||
desc: 'The database index of redis server to be used(Must be less than 10).',
|
||||
default: 0,
|
||||
env: ['REDIS_SERVER_DATABASE', 'integer'],
|
||||
validate: val => val >= 0 && val < 10,
|
||||
shape: z.number().int().nonnegative().max(10),
|
||||
},
|
||||
host: {
|
||||
desc: 'The host of the redis server.',
|
||||
|
||||
Reference in New Issue
Block a user