Skip to content

Latest commit

 

History

History
36 lines (25 loc) · 817 Bytes

File metadata and controls

36 lines (25 loc) · 817 Bytes

Formatting Message

The $validator->format(), by default, the messages will be formatted to html <ul><li></li>...</ul> element.

You can create your own class to format the array $validator->messages() into a well formed result.

use Devknown\Validator\Contracts\Format\FormatInterface;

class MarkdownFormatter implements FormatInterface
{
    public function reformat($messages)
    {
        $ret = '#### Error Found';

        foreach ($messages as $field => $message) {

            foreach ($message as $content) {

                $ret .= "- [x] ".$content."**\n"
            }
        }

        return $ret;
    }
}

Then in to use this call, you must do this way: Then to use your class, you may follow bellow.

$v = V::make([...]);

echo $v->format(MarkdownFormatter::class);