agavi/agavi — pull request #1500 by graste (2014-03-25 23:15:15+00:00)
Title: Allow named parameters and arguments in validation errors

This patch allows for the usage of named parameters and arguments in the `error` messages of validators. This enables developers to use the values of arguments or validation parameters like `min` and `max` via a ```sprintf()``` compatible syntax like: ```%param$s must be between %min$03d and %max$03d```. This is especially useful when being used with ```validator_definitions``` and pull request #1497:

```xml

Please fill in %name$s
%name$s needs at least %min$s characters

3

+10 minutes
3

%name$s is wrong, time has elapsed (%cache_time$s) or maximum count of %max_count$s is reached.

```

This PR uses an anonymous function for the ```AgaviToolkit::vksprintf()``` method and thus makes this patch compatible to PHP v5.3+. As that version is specified in the ```composer.json``` anyways this seems to be of no issue, but may be bad for Agavi users still running w/ PHP v5.2.x.