Replies: 1 comment 1 reply
-
+1. In an unreleased version of my (nodejs/server-side) router, I am using some sort of validator for this: router.addRoute({
matcher: endpoint('GET', /^\/user\/(?<userId>[^/]+)$/
{
url: {
userId: chain(getNthVal(), requiredVal(), toNumVal()),
},
query: {
// profile query parameter is optional in this example
profile: chain(atLeastOneVal([undefined, 'short', 'full']), getNthVal()),
},
},
),
handler: ({ match: { result: { pathname, query } } }) => {
return `User id: ${pathname.params.userId}, profile: ${query.profile}.`,
}
}) They are more flexible than just |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How i can describe variants for
:param
and:type
?I need show
errorElement
if param in my route not in variants arrayFeature Request
And, if param not in
variants[paramName]
list -> return errorElementBeta Was this translation helpful? Give feedback.
All reactions