1
0
Эх сурвалжийг харах

fix(settings): enforce trafficDiff max of 100 in UI (#4769)

The trafficDiff InputNumber and form schema lacked an upper bound, so values above 100 were accepted in the UI but rejected by the backend (gte=0,lte=100), failing the entire settings save with a misleading 'request body failed validation' error. Add max=100 to the input and .max(100) to the schema.
MHSanaei 12 цаг өмнө
parent
commit
39b716409a

+ 1 - 1
frontend/src/pages/settings/GeneralTab.tsx

@@ -205,7 +205,7 @@ export default function GeneralTab({ allSetting, updateSetting }: GeneralTabProp
                 onChange={(v) => updateSetting({ expireDiff: Number(v) || 0 })} />
             </SettingListItem>
             <SettingListItem paddings="small" title={t('pages.settings.trafficDiff')} description={t('pages.settings.trafficDiffDesc')}>
-              <InputNumber value={allSetting.trafficDiff} min={0} style={{ width: '100%' }}
+              <InputNumber value={allSetting.trafficDiff} min={0} max={100} style={{ width: '100%' }}
                 onChange={(v) => updateSetting({ trafficDiff: Number(v) || 0 })} />
             </SettingListItem>
           </>

+ 1 - 1
frontend/src/schemas/setting.ts

@@ -16,7 +16,7 @@ export const AllSettingSchema = z.object({
   panelProxy: z.string().optional(),
   pageSize: z.number().int().min(1).max(1000).optional(),
   expireDiff: nonNegativeInt.optional(),
-  trafficDiff: nonNegativeInt.optional(),
+  trafficDiff: nonNegativeInt.max(100).optional(),
   remarkModel: z.string().optional(),
   datepicker: z.enum(['gregorian', 'jalalian']).optional(),
   tgBotEnable: z.boolean().optional(),