PHP code example of bank / mound
1. Go to this page and download the library: Download bank/mound 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/ */
bank / mound example snippets
"bank/mound": "version"
php composer.phar self-update
php composer.phar install
$provider
->rule($key_name)
->attach(Rules::class, $options)
->attach(Rules::class, $options)
$provider
->group($group_name)
->rule($key_name)
->attach(Rules::class, $options)
->attach(Rules::class, $options)
use Mound\Converter;
$provider = new Converter\Provider;
$data = ['test_data1' => ' test_data1'];
$provider
->rule('test_data1')
->attach(Converter\Rules\Trim::class)
->endRule
$data = $provider->exec($data);
# ['test_data1' => 'test_data1']
use Mound\Filter;
$provider = new Filter\Provider;
$data = ['test_data1' => ' test_data1'];
$provider
->rule('test_data1')
->attach(Filter\Rules\NotEmpty::class)
->endRule
$data = $provider->exec($data);
# []
use Mound\Validator;
$provider = new Validator\Provider;
$haystack = ['test_data'];
$data = [
'test_data1' => 'test_data1'
'test_data2' => ''
];
$provider
->rule('test_data1')->attach(Validator\Rules\NotEmpty::class)
->rule('test_data2')->attach(Validator\Rules\NotEmpty::class)
->group('in_array')->rule('test_data1')
->attach(Validator\Rules\InArray::class, [
'haystack' => $haystack
])
->endGroup
$error = $provider->exec($data);
#['test_data2' => 'can't be blank']
$error = $provider->exec($data, ['in_array']);
#['test_data1' => 'is invalid', 'test_data2' => 'can't be blank']