Added vendor/ directory for Composer's installed files
This commit is contained in:
27
vendor/alexgarrett/violin/examples/messages/placeholders/placeholders.php
vendored
Executable file
27
vendor/alexgarrett/violin/examples/messages/placeholders/placeholders.php
vendored
Executable file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Message placeholders.
|
||||
*
|
||||
* Shows the placeholders you can use when defining messages. You can
|
||||
* output the name of the field, the value given by the user, and
|
||||
* the arguments that were passed into the rule.
|
||||
*/
|
||||
|
||||
require '../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addRuleMessage('between', 'The {field} must be between {$0} and {$1}, you gave {value}');
|
||||
|
||||
$v->validate([
|
||||
'age' => ['82', 'required|between(18, 35)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
31
vendor/alexgarrett/violin/examples/messages/placeholders/placeholders_all.php
vendored
Executable file
31
vendor/alexgarrett/violin/examples/messages/placeholders/placeholders_all.php
vendored
Executable file
@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Violin example. Message placeholders.
|
||||
*
|
||||
* Shows how you can output all arguments as a comma seperated list,
|
||||
* if you have a variable amount of arguments for a rule.
|
||||
*/
|
||||
|
||||
require '../../../vendor/autoload.php';
|
||||
|
||||
use Violin\Violin;
|
||||
|
||||
$v = new Violin;
|
||||
|
||||
$v->addRuleMessage('isoneof', '{field} must be one of {$*}');
|
||||
|
||||
$v->addRule('isoneof', function($value, $input, $args) {
|
||||
$value = trim($value);
|
||||
return in_array($value, $args);
|
||||
});
|
||||
|
||||
$v->validate([
|
||||
'age' => ['sheep', 'required|isoneof(apples, pears)']
|
||||
]);
|
||||
|
||||
if ($v->passes()) {
|
||||
// Passed
|
||||
} else {
|
||||
var_dump($v->errors()->all());
|
||||
}
|
Reference in New Issue
Block a user