mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-19 05:55:34 +09:00
fix(limits): drop removed limit keys from stored rules (#3520)
This commit is contained in:
1 parent
ab7feb42e6
commit
3740c418ec
3 files changed
+159
-15
No files matched your search
@@ -951,14 +951,12 @@ const LimitRuleSchema = z.object({
|
||||
filters: LimitFilterSchema.optional().describe('Optional filters that scope the rule'),
|
||||
limits: z
|
||||
.record(z.string(), NonNegativeSafeIntegerType)
|
||||
.refine(
|
||||
(limits) => {
|
||||
const limitKeys = Object.keys(limits);
|
||||
return limitKeys.every((key) => (LIMIT_KEYS as ReadonlyArray<string>).includes(key));
|
||||
},
|
||||
{error: 'Invalid limit key detected'},
|
||||
)
|
||||
.superRefine((limits, ctx) => {
|
||||
for (const key of Object.keys(limits)) {
|
||||
if (!(LIMIT_KEYS as ReadonlyArray<string>).includes(key)) {
|
||||
ctx.addIssue({code: 'custom', message: ValidationErrorCodes.INVALID_FORMAT, path: [key]});
|
||||
}
|
||||
}
|
||||
for (const key of LIMIT_KEYS) {
|
||||
const value = limits[key];
|
||||
const {min = 0, max} = LIMIT_KEY_METADATA[key];
|
||||
|
||||
Reference in new issue
Block a user