fix: map numeric spec enum keys

This commit is contained in:
Chirag Aggarwal
2026-05-26 11:33:25 +05:30
parent a4d889145b
commit c7caf8d23d
2 changed files with 16 additions and 2 deletions
+7 -1
View File
@@ -32,7 +32,13 @@ Http::get('/v1/project/usage')
))
->param('startDate', '', new DateTimeValidator(), 'Starting date for the usage')
->param('endDate', '', new DateTimeValidator(), 'End date for the usage')
->param('period', '1d', new WhiteList(['1h', '1d']), 'Period used', true, enum: new Enum(name: 'ProjectUsageRange'))
->param('period', '1d', new WhiteList(['1h', '1d']), 'Period used', true, enum: new Enum(
name: 'ProjectUsageRange',
map: [
'1h' => 'OneHour',
'1d' => 'OneDay',
]
))
->inject('response')
->inject('project')
->inject('dbForProject')
@@ -67,7 +67,15 @@ class Create extends Action
->label('abuse-time', 60)
->param('domain', null, new ValidatorDomain(), 'Domain name.')
->param('url', null, new URL(), 'Target URL of redirection')
->param('statusCode', null, new WhiteList([301, 302, 307, 308]), 'Status code of redirection', enum: new Enum(name: 'RedirectStatusCode'))
->param('statusCode', null, new WhiteList([301, 302, 307, 308]), 'Status code of redirection', enum: new Enum(
name: 'RedirectStatusCode',
map: [
'301' => 'MovedPermanently',
'302' => 'Found',
'307' => 'TemporaryRedirect',
'308' => 'PermanentRedirect',
]
))
->param('resourceId', '', fn (Database $dbForProject) => new UID($dbForProject->getAdapter()->getMaxUIDLength()), 'ID of parent resource.', false, ['dbForProject'])
->param('resourceType', '', new WhiteList(['site', 'function']), 'Type of parent resource.', enum: new Enum(
name: 'ProxyResourceType',