Laravel Validation - custom rule, custom error message
<p>I'm extending the Laravel Validation rules to create a rule for "between two user-supplied fields" - the <code>between</code> rule only handles "between two values".</p>

<pre><code>Validator::extend('between_fields', function($attribute, $value, $parameters, $validator) {
    $data = $validator-&gt;getData();

    $min = array_get( $data, $parameters[0], $parameters[0] );
    $max = array_get( $data, $parameters[1], $parameters[1] );

    return $value &gt;= $min &amp;&amp; $value &lt;= $max;
});
</code></pre>

<p>This works fine, but I'd then like to define an error message which uses the numeric values. I've set up a message like this:</p>

<pre><code>'between_fields' =&gt; ':attribute must be between :min and :max.',
</code></pre>

<p>...which is how the existing <code>between</code> rule works, but the <code>:min</code> and <code>:max</code> don't get replaced with anything.</p>

<p>How do I pass the values for those from the Validator extension through to the message handler?</p>