Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] - Parameter validation conditions for the router #79

Closed
javad-zobeidi opened this issue Jun 15, 2024 · 0 comments
Closed
Assignees
Labels
feature request Proposals for new features
Milestone

Comments

@javad-zobeidi
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
I find it challenging to manually validate route parameters in the Router class. This process requires defining parameter types individually for each route, which is repetitive and increases the risk of errors.

Describe the solution you'd like
I would like the Router class to have built-in methods for parameter validation, such as whereInt, whereString, and where, which can be applied directly when defining routes. This would streamline the routing process and ensure that parameters are validated correctly.

Describe alternatives you've considered
I've considered manually adding validation logic within each route's action, but this approach is not scalable and clutters the codebase. Another alternative is using middleware for validation, but this still requires additional setup for each route.

Additional context
Here is an example of how the improved Router class could be used:

Router.get('my-route/{id}', (int id) {
  return Response.json(id);
}).whereInt('id');

Router.get('my-route/show', () {
  return Response.json({'message': 'Show route'});
});

Router.get('my-route/{slug}', (String slug) {
      return Response.json(slug);
    }).where('slug', r'[a-z0-9-]+');
@javad-zobeidi javad-zobeidi added the feature request Proposals for new features label Jun 15, 2024
@javad-zobeidi javad-zobeidi changed the title [Feature Request] - Add parameter validation conditions for the router [Feature Request] - Parameter validation conditions for the router Jun 15, 2024
@javad-zobeidi javad-zobeidi self-assigned this Jun 15, 2024
@javad-zobeidi javad-zobeidi added this to the 0.3.0 milestone Jun 15, 2024
javad-zobeidi added a commit to javad-zobeidi/framework that referenced this issue Jun 15, 2024
Add Resource and Any route (vania-dart#80)
Refactor Router,Route Handler
@javad-zobeidi javad-zobeidi closed this as completed by moving to Completed in Development Roadmap Jun 15, 2024
@javad-zobeidi javad-zobeidi mentioned this issue Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request Proposals for new features
Projects
Status: Completed
Development

No branches or pull requests

1 participant