PHP code example of askedio / laravel-validator-filter

1. Go to this page and download the library: Download askedio/laravel-validator-filter library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

askedio / laravel-validator-filter example snippets


$validator = app('validator')->make([
  'string' => 'Hello ' . PHP_EOL . ' World',
], [
  'string' => 'filter:strip_tags,nl2br',
]);

$validator->passes();

dd($validator->getData());

$validator = app('validator')->make([
  'string' => 'Hello <br> World<p></p>',
], [
  'string' => 'filter:strip_tags[{$value}; "<br>"]',
]);

$validator->passes();

dd($validator->getData());

app('filter')->register('plusOne', function ($value) {
    return $value+1;
});

$validator = app('validator')->make([
  'int' => '<br>1',
], [
  'int' => 'filter:strip_tags,plusOne',
]);

$validator->passes();

dd($validator->getData());