classes/Input/ModelValidator.php
protected function removePrefixFromMessages($prefix, $validator)
    {
        // Get all the rules in a single flat array
        $rules = array_flatten($validator->getRules());

        // Get just the rules, not rule modifiers
        $rules = array_map(function($rule) {
            preg_match('#^([^:]+)#', $rule, $matches);
            return $matches[1];
        }, $rules);

        // Callback that removes isntances of the prefix from a message. Laravel
        // will have already replaced underscores with spaces, so we need to
        // reverse that.
        $prefix = str_replace('_', ' ', $prefix);
        $replacer = function ($message) use ($prefix) {
            return str_replace($prefix, '', $message);
        };

        // Create an array of identical replacer functions
        $replacers = array_fill(0, count($rules), $replacer);

        // Add the replacers to the validtor
        $validator->addReplacers(array_combine($rules, $replacers));
    }
protected function removePrefixFromMessages($prefix, $validator)
    {
        // Get all the rules in a single flat array
        $rules = array_flatten($validator->getRules());

        // Get just the rules, not rule modifiers
        $rules = array_map(function($rule) {
            preg_match('#^([^:]+)#', $rule, $matches);
            return $matches[1];
        }, $rules);

        // Callback that removes isntances of the prefix from a message. Laravel
        // will have already replaced underscores with spaces, so we need to
        // reverse that.
        $prefix = str_replace('_', ' ', $prefix);
        $replacer = function ($message) use ($prefix) {
            return str_replace($prefix, '', $message);
        };

        // Create an array of identical replacer functions
        $replacers = array_fill(0, count($rules), $replacer);

        // Add the replacers to the validtor
        $validator->addReplacers(array_combine($rules, $replacers));
    }
protected function removePrefixFromMessages ( $ prefix , $ validator ) { // Get all the rules in a single flat array $ rules = array_flatten ( $ validator -> getRules ( ) ) ; // Get just the rules, not rule modifiers $ rules = array_map ( function ( $ rule ) { preg_match ( '#^([^:]+)#' , $ rule , $ matches ) ; return $ matches [ 1 ] ; } , $ rules ) ; // Callback that removes isntances of the prefix from a message. Laravel // will have already replaced underscores with spaces, so we need to // reverse that. $ prefix = str_replace ( '_' , ' ' , $ prefix ) ; $ replacer = function ( $ message ) use ( $ prefix ) { return str_replace ( $ prefix , '' , $ message ) ; } ; // Create an array of identical replacer functions $ replacers = array_fill ( 0 , count ( $ rules ) , $ replacer ) ; // Add the replacers to the validtor $ validator -> addReplacers ( array_combine ( $ rules , $ replacers ) ) ; }
Add replacers to the validator that strip back out the prefix

@param  string                          $prefix
@param  Illuminate\Validation\Validator $validator
@return void
Add replacers to the validator that strip back out the prefix