Skip to content

Allow RegEx constraints for new parameters #5

@splashsky

Description

@splashsky

The next big priority item is to accept a RegEx constraint for router parameters, via a method that can be chained onto a route method. This would look something like this:

// Single parameter
Router::get('/hello/{name}', function ($n) {
    return "Hello, $n!";
})->where('name', '[A-Za-z0-9]+');

// Multi parameter
Router::get('/hello/{name}/age/{num}', function ($n, $a) {
    return "Hello, $a yo named $n!";
})->where(['name' => '[A-Za-z0-9]+', 'num' => '[0-9]+']);

This ensures the user can have the level of control they want, while keeping it concise and clean.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions