forked from devsam/core
Valitron을 composer에 추가
This commit is contained in:
+2
-1
@@ -13,7 +13,8 @@
|
||||
"guzzlehttp/guzzle": "^6.3",
|
||||
"leafo/scssphp": "^0.7.5",
|
||||
"monolog/monolog": "^1.23",
|
||||
"firephp/firephp-core": "^0.4.0"
|
||||
"firephp/firephp-core": "^0.4.0",
|
||||
"vlucas/valitron": "^1.4"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
|
||||
Generated
+47
-1
@@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "e6524423ca2d85ab67a07868005fbee0",
|
||||
"content-hash": "4659ec09c50a2ccd1b53194b3f53890a",
|
||||
"packages": [
|
||||
{
|
||||
"name": "brandonwamboldt/utilphp",
|
||||
@@ -593,6 +593,52 @@
|
||||
"pdo"
|
||||
],
|
||||
"time": "2014-06-16T22:40:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "vlucas/valitron",
|
||||
"version": "v1.4.2",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vlucas/valitron.git",
|
||||
"reference": "87775d76268beda2afa085bdd6e44b17e98907c6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/vlucas/valitron/zipball/87775d76268beda2afa085bdd6e44b17e98907c6",
|
||||
"reference": "87775d76268beda2afa085bdd6e44b17e98907c6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Valitron": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Vance Lucas",
|
||||
"email": "vance@vancelucas.com",
|
||||
"homepage": "http://www.vancelucas.com"
|
||||
}
|
||||
],
|
||||
"description": "Simple, elegant, stand-alone validation library with NO dependencies",
|
||||
"homepage": "http://github.com/vlucas/valitron",
|
||||
"keywords": [
|
||||
"valid",
|
||||
"validation",
|
||||
"validator"
|
||||
],
|
||||
"time": "2017-10-30T23:15:06+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
||||
+1
@@ -7,4 +7,5 @@ $baseDir = dirname($vendorDir);
|
||||
|
||||
return array(
|
||||
'utilphp\\' => array($vendorDir . '/brandonwamboldt/utilphp/src'),
|
||||
'Valitron' => array($vendorDir . '/vlucas/valitron/src'),
|
||||
);
|
||||
|
||||
Vendored
+7
@@ -96,6 +96,13 @@ class ComposerStaticInit67b09c83b85c3bc0027caefe5bba171a
|
||||
0 => __DIR__ . '/..' . '/brandonwamboldt/utilphp/src',
|
||||
),
|
||||
),
|
||||
'V' =>
|
||||
array (
|
||||
'Valitron' =>
|
||||
array (
|
||||
0 => __DIR__ . '/..' . '/vlucas/valitron/src',
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
public static $classMap = array (
|
||||
|
||||
Vendored
+48
@@ -608,5 +608,53 @@
|
||||
"mysqli",
|
||||
"pdo"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "vlucas/valitron",
|
||||
"version": "v1.4.2",
|
||||
"version_normalized": "1.4.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vlucas/valitron.git",
|
||||
"reference": "87775d76268beda2afa085bdd6e44b17e98907c6"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/vlucas/valitron/zipball/87775d76268beda2afa085bdd6e44b17e98907c6",
|
||||
"reference": "87775d76268beda2afa085bdd6e44b17e98907c6",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"time": "2017-10-30T23:15:06+00:00",
|
||||
"type": "library",
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Valitron": "src/"
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Vance Lucas",
|
||||
"email": "vance@vancelucas.com",
|
||||
"homepage": "http://www.vancelucas.com"
|
||||
}
|
||||
],
|
||||
"description": "Simple, elegant, stand-alone validation library with NO dependencies",
|
||||
"homepage": "http://github.com/vlucas/valitron",
|
||||
"keywords": [
|
||||
"valid",
|
||||
"validation",
|
||||
"validator"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
The BSD 3-Clause License
|
||||
http://opensource.org/licenses/BSD-3-Clause
|
||||
|
||||
Copyright (c) 2013, Vance Lucas
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
* Neither the name of the Vance Lucas nor the names of its contributors
|
||||
may be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
||||
PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
||||
HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
Vendored
+380
@@ -0,0 +1,380 @@
|
||||
## Valitron: Easy Validation That Doesn't Suck
|
||||
|
||||
Valitron is a simple, minimal and elegant stand-alone validation library
|
||||
with NO dependencies. Valitron uses simple, straightforward validation
|
||||
methods with a focus on readable and concise syntax. Valitron is the
|
||||
simple and pragmatic validation library you've been looking for.
|
||||
|
||||
[](https://travis-ci.org/vlucas/valitron)
|
||||
[](https://packagist.org/packages/vlucas/valitron)
|
||||
[](https://packagist.org/packages/vlucas/valitron)
|
||||
|
||||
## Why Valitron?
|
||||
|
||||
Valitron was created out of frustration with other validation libraries
|
||||
that have dependencies on large components from other frameworks like
|
||||
Symfony's HttpFoundation, pulling in a ton of extra files that aren't
|
||||
really needed for basic validation. It also has purposefully simple
|
||||
syntax used to run all validations in one call instead of individually
|
||||
validating each value by instantiating new classes and validating values
|
||||
one at a time like some other validation libraries require.
|
||||
|
||||
In short, Valitron is everything you've been looking for in a validation
|
||||
library but haven't been able to find until now: simple pragmatic
|
||||
syntax, lightweight code that makes sense, extensible for custom
|
||||
callbacks and validations, well tested, and without dependencies. Let's
|
||||
get started.
|
||||
|
||||
## Installation
|
||||
|
||||
Valitron uses [Composer](http://getcomposer.org) to install and update:
|
||||
|
||||
```
|
||||
curl -s http://getcomposer.org/installer | php
|
||||
php composer.phar require vlucas/valitron
|
||||
```
|
||||
|
||||
The examples below use PHP 5.4 syntax, but Valitron works on PHP 5.3+.
|
||||
|
||||
## Usage
|
||||
|
||||
Usage is simple and straightforward. Just supply an array of data you
|
||||
wish to validate, add some rules, and then call `validate()`. If there
|
||||
are any errors, you can call `errors()` to get them.
|
||||
|
||||
```php
|
||||
$v = new Valitron\Validator(array('name' => 'Chester Tester'));
|
||||
$v->rule('required', 'name');
|
||||
if($v->validate()) {
|
||||
echo "Yay! We're all good!";
|
||||
} else {
|
||||
// Errors
|
||||
print_r($v->errors());
|
||||
}
|
||||
```
|
||||
|
||||
Using this format, you can validate `$_POST` data directly and easily,
|
||||
and can even apply a rule like `required` to an array of fields:
|
||||
|
||||
```php
|
||||
$v = new Valitron\Validator($_POST);
|
||||
$v->rule('required', ['name', 'email']);
|
||||
$v->rule('email', 'email');
|
||||
if($v->validate()) {
|
||||
echo "Yay! We're all good!";
|
||||
} else {
|
||||
// Errors
|
||||
print_r($v->errors());
|
||||
}
|
||||
```
|
||||
|
||||
You may use dot syntax to access members of multi-dimensional arrays,
|
||||
and an asterisk to validate each member of an array:
|
||||
|
||||
```php
|
||||
$v = new Valitron\Validator(array('settings' => array(
|
||||
array('threshold' => 50),
|
||||
array('threshold' => 90)
|
||||
)));
|
||||
$v->rule('max', 'settings.*.threshold', 100);
|
||||
if($v->validate()) {
|
||||
echo "Yay! We're all good!";
|
||||
} else {
|
||||
// Errors
|
||||
print_r($v->errors());
|
||||
}
|
||||
```
|
||||
|
||||
Setting language and language dir globally:
|
||||
|
||||
```php
|
||||
|
||||
// boot or config file
|
||||
|
||||
use Valitron\Validator as V;
|
||||
|
||||
V::langDir(__DIR__.'/validator_lang'); // always set langDir before lang.
|
||||
V::lang('ar');
|
||||
|
||||
```
|
||||
|
||||
|
||||
|
||||
## Built-in Validation Rules
|
||||
|
||||
* `required` - Field is required
|
||||
* `equals` - Field must match another field (email/password confirmation)
|
||||
* `different` - Field must be different than another field
|
||||
* `accepted` - Checkbox or Radio must be accepted (yes, on, 1, true)
|
||||
* `numeric` - Must be numeric
|
||||
* `integer` - Must be integer number
|
||||
* `boolean` - Must be boolean
|
||||
* `array` - Must be array
|
||||
* `length` - String must be certain length
|
||||
* `lengthBetween` - String must be between given lengths
|
||||
* `lengthMin` - String must be greater than given length
|
||||
* `lengthMax` - String must be less than given length
|
||||
* `min` - Minimum
|
||||
* `max` - Maximum
|
||||
* `in` - Performs in_array check on given array values
|
||||
* `notIn` - Negation of `in` rule (not in array of values)
|
||||
* `ip` - Valid IP address
|
||||
* `email` - Valid email address
|
||||
* `url` - Valid URL
|
||||
* `urlActive` - Valid URL with active DNS record
|
||||
* `alpha` - Alphabetic characters only
|
||||
* `alphaNum` - Alphabetic and numeric characters only
|
||||
* `slug` - URL slug characters (a-z, 0-9, -, \_)
|
||||
* `regex` - Field matches given regex pattern
|
||||
* `date` - Field is a valid date
|
||||
* `dateFormat` - Field is a valid date in the given format
|
||||
* `dateBefore` - Field is a valid date and is before the given date
|
||||
* `dateAfter` - Field is a valid date and is after the given date
|
||||
* `contains` - Field is a string and contains the given string
|
||||
* `creditCard` - Field is a valid credit card number
|
||||
* `instanceOf` - Field contains an instance of the given class
|
||||
* `optional` - Value does not need to be included in data array. If it is however, it must pass validation.
|
||||
|
||||
**NOTE**: If you are comparing floating-point numbers with min/max validators, you
|
||||
should install the [BCMath](http://us3.php.net/manual/en/book.bc.php)
|
||||
extension for greater accuracy and reliability. The extension is not required
|
||||
for Valitron to work, but Valitron will use it if available, and it is highly
|
||||
recommended.
|
||||
|
||||
## Required fields
|
||||
the `required` rule checks if a field exists in the data array, and is not null or an empty string.
|
||||
```php
|
||||
$v->rule('required', 'field_name');
|
||||
```
|
||||
|
||||
Using an extra parameter, you can make this rule more flexible, and only check if the field exists in the data array.
|
||||
```php
|
||||
$v->rule('required', 'field_name', true);
|
||||
```
|
||||
## Credit Card Validation usage
|
||||
|
||||
Credit card validation currently allows you to validate a Visa `visa`,
|
||||
Mastercard `mastercard`, Dinersclub `dinersclub`, American Express `amex`
|
||||
or Discover `discover`
|
||||
|
||||
This will check the credit card against each card type
|
||||
|
||||
```php
|
||||
$v->rule('creditCard', 'credit_card');
|
||||
```
|
||||
|
||||
To optionally filter card types, add the slug to an array as the next parameter:
|
||||
|
||||
```php
|
||||
$v->rule('creditCard', 'credit_card', ['visa', 'mastercard']);
|
||||
```
|
||||
|
||||
If you only want to validate one type of card, put it as a string:
|
||||
|
||||
```php
|
||||
$v->rule('creditCard', 'credit_card', 'visa');
|
||||
```
|
||||
|
||||
If the card type information is coming from the client, you might also want to
|
||||
still specify an array of valid card types:
|
||||
|
||||
```php
|
||||
$cardType = 'amex';
|
||||
$v->rule('creditCard', 'credit_card', $cardType, ['visa', 'mastercard']);
|
||||
$v->validate(); // false
|
||||
```
|
||||
|
||||
|
||||
## Adding Custom Validation Rules
|
||||
|
||||
To add your own validation rule, use the `addRule` method with a rule
|
||||
name, a custom callback or closure, and a error message to display in
|
||||
case of an error. The callback provided should return boolean true or
|
||||
false.
|
||||
|
||||
```php
|
||||
Valitron\Validator::addRule('alwaysFail', function($field, $value, array $params, array $fields) {
|
||||
return false;
|
||||
}, 'Everything you do is wrong. You fail.');
|
||||
```
|
||||
|
||||
You can also use one-off rules that are only valid for the specified
|
||||
fields.
|
||||
|
||||
```php
|
||||
$v = new Valitron\Validator(array("foo" => "bar"));
|
||||
$v->rule(function($field, $value, $params, $fields) {
|
||||
return true;
|
||||
}, "foo")->message("{field} failed...");
|
||||
```
|
||||
|
||||
This is useful because such rules can have access to variables
|
||||
defined in the scope where the `Validator` lives. The Closure's
|
||||
signature is identical to `Validator::addRule` callback's
|
||||
signature.
|
||||
|
||||
If you wish to add your own rules that are not static (i.e.,
|
||||
your rule is not static and available to call `Validator`
|
||||
instances), you need to use `Validator::addInstanceRule`.
|
||||
This rule will take the same parameters as
|
||||
`Validator::addRule` but it has to be called on a `Validator`
|
||||
instance.
|
||||
|
||||
|
||||
## Alternate syntax for adding rules
|
||||
|
||||
As the number of rules grows, you may prefer the alternate syntax
|
||||
for defining multiple rules at once.
|
||||
|
||||
```php
|
||||
$rules = [
|
||||
'required' => 'foo',
|
||||
'accepted' => 'bar',
|
||||
'integer' => 'bar'
|
||||
];
|
||||
|
||||
$v = new Valitron\Validator(array('foo' => 'bar', 'bar' => 1));
|
||||
$v->rules($rules);
|
||||
$v->validate();
|
||||
```
|
||||
|
||||
If your rule requires multiple parameters or a single parameter
|
||||
more complex than a string, you need to wrap the rule in an array.
|
||||
|
||||
```php
|
||||
$rules = [
|
||||
'required' => [
|
||||
['foo'],
|
||||
['bar']
|
||||
],
|
||||
'length' => [
|
||||
['foo', 3]
|
||||
]
|
||||
];
|
||||
```
|
||||
You can also specify multiple rules for each rule type.
|
||||
|
||||
```php
|
||||
$rules = [
|
||||
'length' => [
|
||||
['foo', 5],
|
||||
['bar', 5]
|
||||
]
|
||||
];
|
||||
```
|
||||
|
||||
Putting these techniques together, you can create a complete
|
||||
rule definition in a relatively compact data structure.
|
||||
|
||||
You can continue to add individual rules with the `rule` method
|
||||
even after specifying a rule definition via an array. This is
|
||||
especially useful if you are defining custom validation rules.
|
||||
|
||||
```php
|
||||
$rules = [
|
||||
'required' => 'foo',
|
||||
'accepted' => 'bar',
|
||||
'integer' => 'bar'
|
||||
];
|
||||
|
||||
$v = new Valitron\Validator(array('foo' => 'bar', 'bar' => 1));
|
||||
$v->rules($rules);
|
||||
$v->rule('min', 'bar', 0);
|
||||
$v->validate();
|
||||
```
|
||||
|
||||
You can also add rules on a per-field basis:
|
||||
```php
|
||||
$rules = [
|
||||
'required',
|
||||
['lengthMin', 4]
|
||||
];
|
||||
|
||||
$v = new Valitron\Validator(array('foo' => 'bar'));
|
||||
$v->mapFieldRules('foo', $rules);
|
||||
$v->validate();
|
||||
```
|
||||
|
||||
Or for multiple fields at once:
|
||||
|
||||
```php
|
||||
$rules = [
|
||||
'foo' => ['required', 'integer'],
|
||||
'bar'=>['email', ['lengthMin', 4]]
|
||||
];
|
||||
|
||||
$v = new Valitron\Validator(array('foo' => 'bar', 'bar' => 'mail@example.com));
|
||||
$v->mapFieldsRules($rules);
|
||||
$v->validate();
|
||||
```
|
||||
|
||||
## Adding field label to messages
|
||||
|
||||
You can do this in two different ways, you can add a individual label to a rule or an array of all labels for the rules.
|
||||
|
||||
To add individual label to rule you simply add the `label` method after the rule.
|
||||
|
||||
```php
|
||||
$v = new Valitron\Validator(array());
|
||||
$v->rule('required', 'name')->message('{field} is required')->label('Name');
|
||||
$v->validate();
|
||||
```
|
||||
|
||||
There is a edge case to this method, you wouldn't be able to use a array of field names in the rule definition, so one rule per field. So this wouldn't work:
|
||||
|
||||
```php
|
||||
$v = new Valitron\Validator(array());
|
||||
$v->rule('required', array('name', 'email'))->message('{field} is required')->label('Name');
|
||||
$v->validate();
|
||||
```
|
||||
|
||||
However we can use a array of labels to solve this issue by simply adding the `labels` method instead:
|
||||
|
||||
```php
|
||||
$v = new Valitron\Validator(array());
|
||||
$v->rule('required', array('name', 'email'))->message('{field} is required');
|
||||
$v->labels(array(
|
||||
'name' => 'Name',
|
||||
'email' => 'Email address'
|
||||
));
|
||||
$v->validate();
|
||||
```
|
||||
|
||||
This introduces a new set of tags to your error language file which looks like `{field}`, if you are using a rule like `equals` you can access the second value in the language file by incrementing the field with a value like `{field1}`.
|
||||
|
||||
|
||||
## Re-use of validation rules
|
||||
|
||||
You can re-use your validation rules to quickly validate different data with the same rules by using the withData method:
|
||||
|
||||
```php
|
||||
$v = new Valitron\Validator(array());
|
||||
$v->rule('required', 'name')->message('{field} is required');
|
||||
$v->validate(); //false
|
||||
|
||||
$v2 = $v->withData(array('name'=>'example'));
|
||||
$v2->validate(); //true
|
||||
```
|
||||
|
||||
## Running Tests
|
||||
|
||||
The test suite depends on the Composer autoloader to load and run the
|
||||
Valitron files. Please ensure you have downloaded and installed Composer
|
||||
before running the tests:
|
||||
|
||||
1. Download Composer `curl -s http://getcomposer.org/installer | php`
|
||||
2. Run 'install' `php composer.phar install`
|
||||
3. Run the tests `phpunit`
|
||||
|
||||
## Contributing
|
||||
|
||||
1. Fork it
|
||||
2. Create your feature branch (`git checkout -b my-new-feature`)
|
||||
3. Make your changes
|
||||
4. Run the tests, adding new ones for your own code if necessary (`phpunit`)
|
||||
5. Commit your changes (`git commit -am 'Added some feature'`)
|
||||
6. Push to the branch (`git push origin my-new-feature`)
|
||||
7. Create new Pull Request
|
||||
8. Pat yourself on the back for being so awesome
|
||||
|
||||
Vendored
+29
@@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "vlucas/valitron",
|
||||
"type": "library",
|
||||
"description": "Simple, elegant, stand-alone validation library with NO dependencies",
|
||||
"keywords": ["validation", "validator", "valid"],
|
||||
"homepage": "http://github.com/vlucas/valitron",
|
||||
"license" : "BSD",
|
||||
"authors" : [
|
||||
{
|
||||
"name": "Vance Lucas",
|
||||
"email": "vance@vancelucas.com",
|
||||
"homepage": "http://www.vancelucas.com"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.2"
|
||||
},
|
||||
"require-dev": {
|
||||
"phpunit/phpunit": "~4.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Valitron": "src/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"test": "./vendor/bin/phpunit"
|
||||
}
|
||||
}
|
||||
Vendored
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "مطلوب",
|
||||
'equals' => "يجب أن يكون مساوي لي '%s'",
|
||||
'different' => "يجب ان يكون غير '%s'",
|
||||
'accepted' => "يجب ان يكون نعم",
|
||||
'numeric' => "يجب ان يكون رقم",
|
||||
'integer' => "يجب ان يكون رقم (0-9)",
|
||||
'length' => "يجب ان يكون أطول من %d",
|
||||
'min' => "يجب ان يكون اعلي من %s",
|
||||
'max' => "يجب ان يكون اقل من %s",
|
||||
'in' => "الُمدخل يغير صحيح",
|
||||
'notIn' => "الُمدخل يغير صحيح",
|
||||
'ip' => "رقم الإتصال غير صحيح",
|
||||
'email' => "البريد الألكتروني غير صحيح",
|
||||
'url' => "الرابط غير صحيح",
|
||||
'urlActive' => "يجب أن يكون نطاق فعال",
|
||||
'alpha' => "يجب أن يحتوي فقط علي a-z",
|
||||
'alphaNum' => "يجب ان يحتوي فقط a-z او ارقام 0-9",
|
||||
'slug' => "يجب ان يحتوي فقط علي a-z, و ارقام 0-9, شرطات و خط سفلي",
|
||||
'regex' => "خطا بالصيغة",
|
||||
'date' => "خطا بالتاريخ",
|
||||
'dateFormat' => "يجب ان يكون تاريخ بهذه الصيغة '%s'",
|
||||
'dateBefore' => "التاريخ يجب ان يكون قبل '%s'",
|
||||
'dateAfter' => "التاريخ يجب ان يكون بعد '%s'",
|
||||
'contains' => "يجب ان يحتوي %s"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "mütləqdir",
|
||||
'equals' => "'%s' olmalıdır",
|
||||
'different' => "'%s'-dən fərqli olmalıdır",
|
||||
'accepted' => "Qeyd dilməlidir",
|
||||
'numeric' => "rəqəm olmalıdır",
|
||||
'integer' => "tam ədəd olmalıdır",
|
||||
'length' => "%d qədər uzunluğu olmalıdır",
|
||||
'min' => "minimum %s qədər olmalıdır",
|
||||
'max' => "maksimum %s qədər olmalıdır",
|
||||
'in' => "yalnış dəyər ehtiva edir",
|
||||
'notIn' => "yalnış dəyər ehtiva edir",
|
||||
'ip' => "düzgün IP ünvanı deyil",
|
||||
'email' => "düzgün email ünvanı deyil",
|
||||
'url' => "URL deyil",
|
||||
'urlActive' => "aktiv domain olmalıdır",
|
||||
'alpha' => "ancaq latın hərfləri ehtiva etməlidir",
|
||||
'alphaNum' => "ancaq latın hərfləri və(və ya) rəqəmlər ehtiva etməlidir",
|
||||
'slug' => "ancaq latın hərfləri,rəqəmlər,tire və altdan xət ehtiva etməlidir",
|
||||
'regex' => "etiabrsız sinvollar ehtiva edir",
|
||||
'date' => "tarix deyil",
|
||||
'dateFormat' => "tarix formatı bu cür olmalıdır: %s",
|
||||
'dateBefore' => "tarix %s -dən əvvəl olmamalıdır",
|
||||
'dateAfter' => "tarix %s -dən sonra olmamalıdır",
|
||||
'contains' => "%s ehtiva etməlidir",
|
||||
'boolean' => "boolen olmalıdır",
|
||||
'lengthBetween' => "%d - %d sinvolları arası ehtiva etməlidir",
|
||||
'creditCard' => "kredir kart nömrəsi olmalıdır",
|
||||
"lengthMin" => "%d -dən çox sinvol olmalıdır",
|
||||
"lengthMax" => "%d -dən az sinvol olmalıdır",
|
||||
"instanceOf" => "'%s' əvəzinə olmalıdır"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "е задължително",
|
||||
'equals' => "трябва да бъде същото като '%s'",
|
||||
'different' => "трябва да бъде различно от '%s'",
|
||||
'accepted' => "трабва да бъде прието",
|
||||
'numeric' => "трябва да бъде число",
|
||||
'integer' => "трябва да бъде цифра (0-9)",
|
||||
'length' => "трябва да бъде %d символа дълго",
|
||||
'min' => "трябвя да бъде поне %s",
|
||||
'max' => "трябва да бъде не повече от %s",
|
||||
'in' => "съдържа невалидна стойност",
|
||||
'notIn' => "съдържа невалидна стойност",
|
||||
'ip' => "е невалиден IP адрес",
|
||||
'email' => "е невалиден имейл адрес",
|
||||
'url' => "е невалиден URL адрес",
|
||||
'urlActive' => "трябва да бъде активен домейн",
|
||||
'alpha' => "трябва да съдържа само букви a-z",
|
||||
'alphaNum' => "трябва да съдържа само букви a-z и/или цифри 0-9",
|
||||
'slug' => "трябва да съдържа само букви a-z, цифри 0-9, тирета и долни черти",
|
||||
'regex' => "съдържа невалидни символи",
|
||||
'date' => "е невалидна дата",
|
||||
'dateFormat' => "трябва да бъде дата с формат '%s'",
|
||||
'dateBefore' => "трябва да бъде дата преди '%s'",
|
||||
'dateAfter' => "трябва да бъде дата след '%s'",
|
||||
'contains' => "трябв да съдържа %s",
|
||||
'boolean' => "трябва да бъде истина или лъжа",
|
||||
'lengthBetween' => "трябва да бъде между %d и %d символа",
|
||||
'creditCard' => "трябва да бъде валиден номер на кредитна карта",
|
||||
'lengthMin' => "трябва да бъде поне %d символа дълго",
|
||||
'lengthMax' => "не трябва да надвишава %d символа",
|
||||
'instanceOf' => "трябва да бъде инстанция от '%s'"
|
||||
);
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "ist erforderlich",
|
||||
'equals' => "muss identisch mit '%s' sein",
|
||||
'different' => "muss sich von '%s' unterscheiden",
|
||||
'accepted' => "muss markiert sein",
|
||||
'numeric' => "muss eine Zahl sein",
|
||||
'integer' => "muss eine ganze Zahl sein",
|
||||
'length' => "kann nicht länger als %d sein",
|
||||
'min' => "muss größer als %s sein",
|
||||
'max' => "muss kleiner als %s sein",
|
||||
'in' => "enthält einen ungültigen Wert",
|
||||
'notIn' => "enthält einen ungültigen Wert",
|
||||
'ip' => "enthält keine gültige IP-Addresse",
|
||||
'email' => "enthält keine gültige E-Mail-Adresse",
|
||||
'url' => "enthält keine gültige URL",
|
||||
'urlActive' => "muss eine aktive Domain sein",
|
||||
'alpha' => "darf nur Buchstaben enthalten",
|
||||
'alphaNum' => "darf nur Buchstaben und Ganzzahlen enthalten",
|
||||
'slug' => "darf nur Buchstaben, Ganzzahlen, Schrägstriche und Grundstriche enthalten",
|
||||
'regex' => "enthält ungültige Zeichen",
|
||||
'date' => "enthält kein gültiges Datum",
|
||||
'dateFormat' => "benötigt ein Datum im Format '%s'",
|
||||
'dateBefore' => "benötigt ein Datum, das vor dem '%s' liegt",
|
||||
'dateAfter' => "benötigt ein Datum, das nach dem '%s' liegt",
|
||||
'contains' => "muss %s beinhalten",
|
||||
'boolean' => "muss ein Wahrheitswert sein",
|
||||
'lengthBetween' => "benötigt zwischen %d und %d Zeichen",
|
||||
'creditCard' => "muss eine gültige Kreditkartennummer sein",
|
||||
"lengthMin" => "muss mindestens %d Zeichen enthalten",
|
||||
"lengthMax" => "kann nicht mehr als %d Zeichen enthalten"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "είναι απαραίτητο",
|
||||
'equals' => "πρέπει να είναι ίδιο με '%s'",
|
||||
'different' => "πρέπει να διαφέρει από '%s'",
|
||||
'accepted' => "πρέπει να έχει αποδεχτεί",
|
||||
'numeric' => "πρέπει να είναι αριθμός",
|
||||
'integer' => "πρέπει να είναι ακέραιος αριθμός",
|
||||
'length' => "πρέπει να είναι μεγαλύτερο από %d",
|
||||
'min' => "πρέπει να είναι τουλάχιστον %s",
|
||||
'max' => "δεν πρέπει να είναι περισσότερο από %s",
|
||||
'in' => "περιέχει μη έγκυρη τιμή",
|
||||
'notIn' => "περιέχει μη έγκυρη τιμή",
|
||||
'ip' => "δεν είναι έγκυρη διεύθυνση IP",
|
||||
'email' => "δεν είναι έγκυρη διεύθυνση email",
|
||||
'url' => "δεν είναι URL",
|
||||
'urlActive' => "πρέπει να είναι ενεργό domain",
|
||||
'alpha' => "πρέπει να περιέχει μόνο χαρακτήρες",
|
||||
'alphaNum' => "πρέπει να περιέχει μόνο χαρακτήρες και/ή αριθμούς",
|
||||
'slug' => "πρέπει να περιέχει μόνο χαρακτήρες, αριθμούς, παύλες και κάτω παύλες",
|
||||
'regex' => "περιέχει μη έγκυρους χαρακτήρες",
|
||||
'date' => "δεν είναι έγκυρη ημερομηνία",
|
||||
'dateFormat' => "πρέπει να είναι ημερομηνία της μορφής '%s'",
|
||||
'dateBefore' => "πρέπει να είναι ημερομηνία πριν από '%s'",
|
||||
'dateAfter' => "πρέπει να είναι ημερομηνία μετά από '%s'",
|
||||
'contains' => "πρέπει να περιέχει %s",
|
||||
'boolean' => "πρέπει να είναι boolean",
|
||||
'lengthBetween' => "πρέπει να είναι μεταξύ %d και %d χαρακτήρων",
|
||||
'creditCard' => "πρέπει να είναι ένα έγκυρο νούμερο πιστωτικής κάρτας",
|
||||
"lengthMin" => "πρέπει να περιέχει περισσότερους από %d χαρακτήρες",
|
||||
"lengthMax" => "πρέπει να περιέχει λιγότερους από %d χαρακτήρες",
|
||||
"instanceOf" => "πρέπει να είναι αντικείμενο της '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "is required",
|
||||
'equals' => "must be the same as '%s'",
|
||||
'different' => "must be different than '%s'",
|
||||
'accepted' => "must be accepted",
|
||||
'numeric' => "must be numeric",
|
||||
'integer' => "must be an integer",
|
||||
'length' => "must be %d characters long",
|
||||
'min' => "must be at least %s",
|
||||
'max' => "must be no more than %s",
|
||||
'in' => "contains invalid value",
|
||||
'notIn' => "contains invalid value",
|
||||
'ip' => "is not a valid IP address",
|
||||
'email' => "is not a valid email address",
|
||||
'url' => "is not a valid URL",
|
||||
'urlActive' => "must be an active domain",
|
||||
'alpha' => "must contain only letters a-z",
|
||||
'alphaNum' => "must contain only letters a-z and/or numbers 0-9",
|
||||
'slug' => "must contain only letters a-z, numbers 0-9, dashes and underscores",
|
||||
'regex' => "contains invalid characters",
|
||||
'date' => "is not a valid date",
|
||||
'dateFormat' => "must be date with format '%s'",
|
||||
'dateBefore' => "must be date before '%s'",
|
||||
'dateAfter' => "must be date after '%s'",
|
||||
'contains' => "must contain %s",
|
||||
'boolean' => "must be a boolean",
|
||||
'lengthBetween' => "must be between %d and %d characters",
|
||||
'creditCard' => "must be a valid credit card number",
|
||||
'lengthMin' => "must be at least %d characters long",
|
||||
'lengthMax' => "must not exceed %d characters",
|
||||
'instanceOf' => "must be an instance of '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "es obligatorio",
|
||||
'equals' => "debe ser igual a '%s'",
|
||||
'different' => "debe ser diferente a '%s'",
|
||||
'accepted' => "debe ser aceptado",
|
||||
'numeric' => "debe ser numérico",
|
||||
'integer' => "debe ser un entero",
|
||||
'length' => "debe ser mas largo de %d",
|
||||
'min' => "debe ser mayor de %s",
|
||||
'max' => "debe ser menor de %s",
|
||||
'in' => "contiene un valor inválido",
|
||||
'notIn' => "contiene un valor inválido",
|
||||
'ip' => "no es una dirección IP",
|
||||
'email' => "no es un correo electrónico válido",
|
||||
'url' => "no es una URL",
|
||||
'urlActive' => "debe ser un dominio activo",
|
||||
'alpha' => "debe contener solo letras a-z",
|
||||
'alphaNum' => "debe contener solo letras a-z o números 0-9",
|
||||
'slug' => "debe contener solo letras a-z, números 0-9, barras y guiones bajos",
|
||||
'regex' => "contiene caracteres inválidos",
|
||||
'date' => "no es una fecha válida",
|
||||
'dateFormat' => "debe ser una fecha con formato '%s'",
|
||||
'dateBefore' => "debe ser una fecha antes de '%s'",
|
||||
'dateAfter' => "debe ser una fecha después de '%s'",
|
||||
'contains' => "debe contener %s",
|
||||
'boolean' => "debe ser booleano",
|
||||
'lengthBetween' => "debe tener entre %d y %d caracteres",
|
||||
'creditCard' => "debe ser un numero de tarjeta de crédito válido",
|
||||
"lengthMin" => "debe tener al menos %d caracteres",
|
||||
"lengthMax" => "debe tener menos de %d caracteres",
|
||||
"instanceOf" => "debe ser una instancia de '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "vaaditaan",
|
||||
'equals' => "ei ole sama kuin '%s'",
|
||||
'different' => "on sama kuin '%s'",
|
||||
'accepted' => "ei ole hyväksytty",
|
||||
'numeric' => "ei ole numeerinen",
|
||||
'integer' => "ei ole kokonaisluku",
|
||||
'length' => "on lyhyempi kuin %d",
|
||||
'min' => "ei ole vähintään %s",
|
||||
'max' => "ei ole enintään %s",
|
||||
'in' => "sisältää virheellisen arvon",
|
||||
'notIn' => "sisältää virheellisen arvon",
|
||||
'ip' => "ei ole oikeanmuotoinen IP-osoite",
|
||||
'email' => "ei ole oikeanmuotoinen sähköpostiosoite",
|
||||
'url' => "ei ole URL",
|
||||
'urlActive' => "ei ole aktiivinen verkkotunnus",
|
||||
'alpha' => "sisältää muita merkkejä kuin a-z",
|
||||
'alphaNum' => "sisältää muita merkkejä kuin a-z ja 0-9",
|
||||
'slug' => "sisältää muita merkkejä kuin a-z, 0-9, - ja _",
|
||||
'regex' => "sisältää virheellisiä merkkejä",
|
||||
'date' => "ei ole oikeanmuotoinen päivämäärä",
|
||||
'dateFormat' => "ei ole päivämäärä muotoa '%s'",
|
||||
'dateBefore' => "ei ole päivämäärä ennen '%s'",
|
||||
'dateAfter' => "ei ole päivämäärä '%s' jälkeen",
|
||||
'contains' => "ei sisällä merkkijonoa %s",
|
||||
'boolean' => "ei ole totuusarvo",
|
||||
'lengthBetween' => "ei ole %d-%d merkkiä pitkä",
|
||||
'creditCard' => "ei ole pätevä luottokortin numero",
|
||||
"lengthMin" => "ei ole vähintään %d merkkiä pitkä",
|
||||
"lengthMax" => "ei ole enintään %d merkkiä pitkä",
|
||||
"instanceOf" => "ei ole luokan '%s' ilmentymä"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "est obligatoire",
|
||||
'equals' => "doit être identique à '%s'",
|
||||
'different' => "doit être différent de '%s'",
|
||||
'accepted' => "doit être accepté",
|
||||
'numeric' => "doit être numérique",
|
||||
'integer' => "doit être un entier",
|
||||
'length' => "doit être plus long que %d",
|
||||
'min' => "doit être plus grand que %s",
|
||||
'max' => "doit être plus petit que %s",
|
||||
'in' => "contient une valeur non valide",
|
||||
'notIn' => "contient une valeur non valide",
|
||||
'ip' => "n'est pas une adresse IP valide",
|
||||
'email' => "n'est pas une adresse email valide",
|
||||
'url' => "n'est pas une URL",
|
||||
'urlActive' => "doit être un domaine actif",
|
||||
'alpha' => "doit contenir uniquement les lettres a-z",
|
||||
'alphaNum' => "doit contenir uniquement des lettres de a-z et/ou des chiffres 0-9",
|
||||
'slug' => "doit contenir uniquement des lettres de a-z, des chiffres 0-9, des tirets et des traits soulignés",
|
||||
'regex' => "contient des caractères invalides",
|
||||
'date' => "n'est pas une date valide",
|
||||
'dateFormat' => "doit être une date avec le format '%s'",
|
||||
'dateBefore' => "doit être une date avant '%s'",
|
||||
'dateAfter' => "doit être une date après '%s'",
|
||||
'contains' => "doit contenir %s",
|
||||
'boolean' => "doit être un booléen",
|
||||
'lengthBetween' => "doit être entre %d et %d caractères",
|
||||
'creditCard' => "doit être un numéro de carte de crédit valide",
|
||||
'lengthMin' => "doit avoir au moins %d caractères",
|
||||
'lengthMax' => "ne doit pas dépasser %d caractères",
|
||||
'instanceOf' => "doit être une instance de '%s'"
|
||||
);
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "harus diisi",
|
||||
'equals' => "harus sama dengan '%s'",
|
||||
'different' => "harus berbeda dengan '%s'",
|
||||
'accepted' => "harus diterima (accepted)",
|
||||
'numeric' => "harus berupa nomor/angka",
|
||||
'integer' => "harus berupa nilai integer",
|
||||
'length' => "harus lebih panjang dari %d",
|
||||
'min' => "harus lebih besar dari %s",
|
||||
'max' => "harus kurang dari %s",
|
||||
'in' => "berisi nilai/value yang tidak valid",
|
||||
'notIn' => "berisi nilai/value yang tidak valid",
|
||||
'ip' => "format alamat IP tidak benar",
|
||||
'email' => "format alamat email tidak benar",
|
||||
'url' => "bukan format URL yang benar",
|
||||
'urlActive' => "harus berupa domain aktif",
|
||||
'alpha' => "hanya boleh menggunakan huruf a-z",
|
||||
'alphaNum' => "hanya boleh menggunakan huruf a-z dan atau nomor 0-9",
|
||||
'slug' => "hanya boleh menggunakan huruf a-z, nomor 0-9, tanda minus (-), dan uderscore atau strip bawah (_)",
|
||||
'regex' => "berisi karakter yang tidak valid",
|
||||
'date' => "format tanggal tidak valid",
|
||||
'dateFormat' => "harus berupa tanggal dengan format '%s'",
|
||||
'dateBefore' => "tanggal harus sebelum tanggal '%s'",
|
||||
'dateAfter' => "tanggal harus sesudah tanggal '%s'",
|
||||
'contains' => "harus berisi %s",
|
||||
'boolean' => "harus berupa nilai boolean",
|
||||
'lengthBetween' => "harus diantara karakter %d dan %d",
|
||||
'creditCard' => "nomor kartu kredit harus valid",
|
||||
"lengthMin" => "minimal berisi %d karakter",
|
||||
"lengthMax" => "maksimal berisi %d karakter"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "è obbligatorio",
|
||||
'equals' => "deve essere uguale a '%s'",
|
||||
'different' => "deve essere differente da '%s'",
|
||||
'accepted' => "deve essere accettato",
|
||||
'numeric' => "deve essere numerico",
|
||||
'integer' => "deve essere un intero",
|
||||
'length' => "deve avere una lunghezza di %d",
|
||||
'min' => "deve essere superiore a %s",
|
||||
'max' => "deve essere inferiore a %s",
|
||||
'in' => "contiene un valore non valido",
|
||||
'notIn' => "contiene un valore non valido",
|
||||
'ip' => "non è un indirizzo IP valido",
|
||||
'email' => "non è un indirizzo email valido",
|
||||
'url' => "non è una URL",
|
||||
'urlActive' => "deve essere un dominio attivo",
|
||||
'alpha' => "deve contenere solamente lettere (a-z)",
|
||||
'alphaNum' => "deve contenere solamente lettere (a-z) e/o numeri (0-9)",
|
||||
'slug' => "deve contenere solamente lettere (a-z), numeri (0-9), trattini (-) e trattini bassi (_)",
|
||||
'regex' => "contiene caratteri non validi",
|
||||
'date' => "non è una data valida",
|
||||
'dateFormat' => "deve essere una data nel formato '%s'",
|
||||
'dateBefore' => "deve essere una data precedente al '%s'",
|
||||
'dateAfter' => "deve essere una data successiva al '%s'",
|
||||
'contains' => "deve contenere %s",
|
||||
'boolean' => "deve essere un booleano",
|
||||
'lengthBetween' => "deve essere compreso tra %d e %d caratteri",
|
||||
'creditCard' => "deve essere un numero di carta di credito valido",
|
||||
'lengthMin' => "deve essere lungo almeno %d caratteri",
|
||||
'lengthMax' => "non deve superare %d caratteri",
|
||||
'instanceOf' => "deve essere un'istanza di '%s'",
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "を入力してください",
|
||||
'equals' => "は「%s」と同じ内容を入力してください",
|
||||
'different' => "は「%s」と異なる内容を入力してください",
|
||||
'accepted' => "に同意してください",
|
||||
'numeric' => "は数値を入力してください",
|
||||
'integer' => "は半角数字で入力してください",
|
||||
'length' => "は%d文字で入力してください",
|
||||
'min' => "には%sより大きな値を入力してください",
|
||||
'max' => "には%sより小さな値を入力してください",
|
||||
'in' => "には選択できない値が含まれています",
|
||||
'notIn' => "には選択できない値が含まれています",
|
||||
'ip' => "はIPアドレスの書式として正しくありません",
|
||||
'email' => "はメールアドレスの書式として正しくありません",
|
||||
'url' => "はURLの書式として正しくありません",
|
||||
'urlActive' => "はアクティブなドメインではありません",
|
||||
'alpha' => "は半角英字で入力してください",
|
||||
'alphaNum' => "は半角英数字で入力してください",
|
||||
'slug' => "は半角英数字、もしくは「-」「_」の文字で入力してください",
|
||||
'regex' => "の書式が正しくありません",
|
||||
'date' => "は日付の書式として正しくありません",
|
||||
'dateFormat' => "は「%s」の書式で日付を入力してください",
|
||||
'dateBefore' => "は「%s」以前の日付を入力してください",
|
||||
'dateAfter' => "は「%s」以後の日付を入力してください",
|
||||
'contains' => "は「%s」を含んでいなければいけません",
|
||||
'boolean' => "は真偽値である必要があります",
|
||||
'lengthBetween' => "は%d〜%d文字で入力してください",
|
||||
'creditCard' => "はクレジットカード番号の書式として正しくありません",
|
||||
'lengthMin' => "は%d文字以上入力してください",
|
||||
'lengthMax' => "は%d文字以内で入力してください",
|
||||
'instanceOf' => "は「%s」のインスタンスではありません",
|
||||
);
|
||||
Vendored
+31
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "ir obligāts lauks",
|
||||
'equals' => "jāsakrīt ar '%s'",
|
||||
'different' => "nedrīkst sakrist ar '%s' lauku",
|
||||
'accepted' => "laukam jābūt apstiprinātam",
|
||||
'numeric' => "jābūt skaitliskai vērtībai",
|
||||
'integer' => "jābūt ciparam (0-9)",
|
||||
'length' => "nedrīkst būt garāks par %d simboliem",
|
||||
'min' => "jābūt garākam par %s simboliem",
|
||||
'max' => "jābūt īsākam par %s simboliem",
|
||||
'in' => "lauks satur nederīgu vērtību",
|
||||
'notIn' => "lauks satur nederīgu vērtību",
|
||||
'ip' => " lauks nav derīga IP adrese",
|
||||
'email' => "lauks nav norādīta derīga epasta adrese",
|
||||
'url' => "lauks nav tīmekļa saite",
|
||||
'urlActive' => "saite neatrodas esošajā domēna vārdā",
|
||||
'alpha' => "lauks var saturēt tikai alfabēta burtus a-z",
|
||||
'alphaNum' => "lauks var saturēt tikai alfabēta burtus un/vai ciparus 0-9",
|
||||
'slug' => "lauks var saturēt tikai alfabēta burtus un/vai ciparus 0-9, domuzīmes and zemsvītras",
|
||||
'regex' => "lauks satur nederīgus simbolus",
|
||||
'date' => "lauks ir nederīgā datuma formātā",
|
||||
'dateFormat' => "laukam jābūt datuma formātā '%s'",
|
||||
'dateBefore' => "lauka datumam jābūt pirms '%s'",
|
||||
'dateAfter' => "lauka datumam jābūt pēc '%s'",
|
||||
'contains' => "laukam jāsatur %s",
|
||||
'boolean' => "laukam jābūt ir/nav vērtībai",
|
||||
'lengthBetween' => "lauka garumam jābūt no %d līdz %d simbolu garam",
|
||||
'creditCard' => "laukam jābūt derīgam kredītkartes numuram"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "is verplicht",
|
||||
'equals' => "moet gelijk zijn aan '%s'",
|
||||
'different' => "moet verschillend zijn van '%s'",
|
||||
'accepted' => "moet aanvaard worden",
|
||||
'numeric' => "moet numeriek zijn",
|
||||
'integer' => "moet een cijfer zijn",
|
||||
'length' => "moet minstens %d karakters lang zijn",
|
||||
'min' => "moet minstens %s zijn",
|
||||
'max' => "mag niet meer zijn dan %s",
|
||||
'in' => "bevat een ongeldige waarde",
|
||||
'notIn' => "bevat een ongeldige waarde",
|
||||
'ip' => "is geen geldig IP-adres",
|
||||
'email' => "is geen geldig e-mailadres",
|
||||
'url' => "is geen geldige URL",
|
||||
'urlActive' => "moet een actief domein zijn",
|
||||
'alpha' => "mag enkel letters (a-z) bevatten",
|
||||
'alphaNum' => "mag enkel letters (a-z) en/of cijfers (0-9) bevatten",
|
||||
'slug' => "mag enkel letters (a-z), cijfers (0-9) en liggende streepjes (_,-) bevatten",
|
||||
'regex' => "bevat ongeldige karakters",
|
||||
'date' => "is geen geldige datum",
|
||||
'dateFormat' => "moet een datum zijn in het formaat '%s'",
|
||||
'dateBefore' => "moet een datum voor '%s' zijn",
|
||||
'dateAfter' => "moet een datum na '%s' zijn",
|
||||
'contains' => "moet '%s' bevatten",
|
||||
'boolean' => "moet een booleaanse waarde zijn",
|
||||
'lengthBetween' => "moet tussen %d en %d karakters lang zijn",
|
||||
'creditCard' => "moet een geldig kredietkaartnummer zijn",
|
||||
"lengthMin" => "moet meer dan %d karakters lang zijn",
|
||||
"lengthMax" => "mag niet meer dan %d karakters lang zijn",
|
||||
"instanceOf" => "moet een instantie zijn van '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "er nødvendig",
|
||||
'equals' => "må være de samme som '%s'",
|
||||
'different' => "må være annerledes enn '%s'",
|
||||
'accepted' => "må aksepteres",
|
||||
'numeric' => "må være numerisk",
|
||||
'integer' => "må være et heltall",
|
||||
'length' => "må være %d tegn",
|
||||
'min' => "må være minst %s",
|
||||
'max' => "må ikke være mer enn %s",
|
||||
'in' => "inneholder ugyldig verdi",
|
||||
'notIn' => "inneholder ugyldig verdi",
|
||||
'ip' => "er ikkje ein gyldig IP Adresse",
|
||||
'email' => "er ikkje ein gyldig E-post adresse",
|
||||
'url' => "er ikkje ein gyldig URL",
|
||||
'urlActive' => "må være eit aktivt domene",
|
||||
'alpha' => "må bare innholde bokstaver a-z",
|
||||
'alphaNum' => "må bare innholde bokstaver a-z og/eller tall 0-9",
|
||||
'slug' => "må bare innholde bokstaver a-z og/eller tall 0-9, bindestreker og understreker",
|
||||
'regex' => "inneholder ulovlige tegn",
|
||||
'date' => "er ikkje ein gylid dato",
|
||||
'dateFormat' => "må være ein dato med formatet '%s'",
|
||||
'dateBefore' => "må være ein dato før '%s'",
|
||||
'dateAfter' => "må være ein dato etter '%s'",
|
||||
'contains' => "må inneholde %s",
|
||||
'boolean' => "må være ein boolsk verdi",
|
||||
'lengthBetween' => "må være imellom %d og %d tegn",
|
||||
'creditCard' => "må være et gyldig kredittkortnummer",
|
||||
'lengthMin' => "må være minst %d tegn",
|
||||
'lengthMax' => "må ikkje overstige %d tegn",
|
||||
'instanceOf' => "må være ein instans av '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "jest wymagane",
|
||||
'equals' => "musi być takie same jak '%s'",
|
||||
'different' => "musi być różne od '%s'",
|
||||
'accepted' => "musi być zaakceptowane",
|
||||
'numeric' => "musi być liczbą",
|
||||
'integer' => "musi być liczbą całkowitą",
|
||||
'length' => "musi być dłuższe niż %d",
|
||||
'min' => "musi być przynajmniej %s",
|
||||
'max' => "nie może być większe niż %s",
|
||||
'in' => "zawiera nieprawidłową wartość",
|
||||
'notIn' => "zawiera nieprawidłową wartość",
|
||||
'ip' => "nie jest prawidłowym adresem IP",
|
||||
'email' => "nie jest prawidłowym adresem email",
|
||||
'url' => "nie jest URL",
|
||||
'urlActive' => "musi być aktywną domeną",
|
||||
'alpha' => "musi zawierać tylko litery a-z",
|
||||
'alphaNum' => "musi zawierać tylko litery a-z i/lub cyfry 0-9",
|
||||
'slug' => "musi zawierać tylko litery a-z i/lub cyfry 0-9, myślinik I podkreślnik",
|
||||
'regex' => "zawiera nieprawidłowe znaki",
|
||||
'date' => "nie jest prawidłową datą",
|
||||
'dateFormat' => "Data musi być w formacie '%s'",
|
||||
'dateBefore' => "Data musi występować przed '%s'",
|
||||
'dateAfter' => "Data musi następować po '%s'",
|
||||
'contains' => "Musi zawierać %s",
|
||||
'boolean' => "musi być wartością logiczną",
|
||||
'lengthBetween' => "ilość znaków musi być między %d a %d",
|
||||
'creditCard' => "musi być prawidłowym numerem karty kredytowej",
|
||||
"lengthMin" => "musi zawierać więcej niż %d znaków",
|
||||
"lengthMax" => "musi zawierać mniej niż %d znaków",
|
||||
"instanceOf" => "musi być instancją '%s'",
|
||||
);
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "é obrigatório",
|
||||
'equals' => "deve ser o mesmo que '%s'",
|
||||
'different' => "deve ser diferente de '%s'",
|
||||
'accepted' => "deve ser aceito",
|
||||
'numeric' => "deve ser um número",
|
||||
'integer' => "deve ser um inteiro",
|
||||
'length' => "deve ter %d caracteres",
|
||||
'min' => "deve ser maior que %s",
|
||||
'max' => "deve ser menor que %s",
|
||||
'in' => "contém um valor inválido",
|
||||
'notIn' => "contém um valor inválido",
|
||||
'ip' => "não é um IP válido",
|
||||
'email' => "não é um email válido",
|
||||
'url' => "não é uma URL válida",
|
||||
'urlActive' => "deve ser um domínio ativo",
|
||||
'alpha' => "deve conter as letras a-z",
|
||||
'alphaNum' => "deve conter apenas letras a-z e/ou números 0-9",
|
||||
'slug' => "deve conter apenas letras a-z, números 0-9, ou os caracteres - ou _",
|
||||
'regex' => "contém caracteres inválidos",
|
||||
'date' => "não é uma data válida",
|
||||
'dateFormat' => "deve ser uma data no formato '%s'",
|
||||
'dateBefore' => "deve ser uma data anterior a '%s'",
|
||||
'dateAfter' => "deve ser uma data posterior a '%s'",
|
||||
'contains' => "deve conter %s",
|
||||
'boolean' => "deve ser um booleano",
|
||||
'lengthBetween' => "deve estar entre %d e %d caracteres",
|
||||
'creditCard' => "deve ser um numero de cartão de credito válido",
|
||||
'lengthMin' => "deve ter ao menos %d caracteres",
|
||||
'lengthMax' => "não deve exceder %d caracteres",
|
||||
'instanceOf' => "deve ser uma instância de '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "se cere",
|
||||
'equals' => "trebuie sa fie la fel ca '%s'",
|
||||
'different' => "trebuie sa fie diferit de '%s'",
|
||||
'accepted' => "trebuie sa fie acceptat",
|
||||
'numeric' => "trebuie sa fie numeric",
|
||||
'integer' => "trebuie sa fie intreg",
|
||||
'length' => "trebuie sa fie mai lung decat %d",
|
||||
'min' => "trebuie sa fie cel putin %s",
|
||||
'max' => "nu trebuie sa fie mai mult de %s",
|
||||
'in' => "contine caractere invalide",
|
||||
'notIn' => "contine o valoare invalida",
|
||||
'ip' => "nu este o adresa IP valida",
|
||||
'email' => "nu este o adresa de email valida",
|
||||
'url' => "nu este un URL",
|
||||
'urlActive' => "trebuie sa fie un domeniu activ",
|
||||
'alpha' => "trebuie sa contina doar litere de la a-z",
|
||||
'alphaNum' => "trebuie sa contina doar numere de la a-z si/sau numere 0-9",
|
||||
'slug' => "trebuie sa contina doar litere de la a-z, numere de la 0-9, cratime si underline '_'",
|
||||
'regex' => "contine caractere invalide",
|
||||
'date' => "nu este o data valida",
|
||||
'dateFormat' => "trebuie sa fie o data care sa aiba forma '%s'",
|
||||
'dateBefore' => "trebuie sa fie o data inainte de '%s'",
|
||||
'dateAfter' => "trebuie sa fie o data dupa '%s'",
|
||||
'contains' => "trebuie sa contina %s",
|
||||
'boolean' => "trebuie sa fie o constructie logica",
|
||||
'lengthBetween' => "trebuie sa contina intre %d si %d caractere",
|
||||
'creditCard' => "trebuie sa fie nu numar de card de credit valid",
|
||||
"lengthMin" => "trebuie sa contina caractere mai multe decat %d",
|
||||
"lengthMax" => "trebuie sa contina mai putin de %d caractere",
|
||||
"instanceOf" => "trebuie sa fie un exemplu de '%s’",
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "обязательно для заполнения",
|
||||
'equals' => "должно содержать '%s'",
|
||||
'different' => "должно отличаться от '%s'",
|
||||
'accepted' => "должно быть указано",
|
||||
'numeric' => "должно содержать числовое значение",
|
||||
'integer' => "должно быть числом",
|
||||
'length' => "должно быть длиннее, чем %d",
|
||||
'min' => "должно быть больше, чем %s",
|
||||
'max' => "должно быть меньше, чем %s",
|
||||
'in' => "содержит неверное значение",
|
||||
'notIn' => "содержит неверное значение",
|
||||
'ip' => "не является валидным IP адресом",
|
||||
'email' => "не является валидным email адресом",
|
||||
'url' => "не является валидной ссылкой",
|
||||
'urlActive' => "содержит не активную ссылку",
|
||||
'alpha' => "должно содержать только латинские символы",
|
||||
'alphaNum' => "должно содержать только латинские символы и/или цифры",
|
||||
'slug' => "должно содержать только латинские символы, цифры, тире и подчёркивания",
|
||||
'regex' => "содержит недопустимые символы",
|
||||
'date' => "не является датой",
|
||||
'dateFormat' => "должно содержать дату следующего формата: %s",
|
||||
'dateBefore' => "должно содержать дату не позднее, чем %s",
|
||||
'dateAfter' => "должно содержать дату не ранее, чем %s",
|
||||
'contains' => "должно содержать %s",
|
||||
'boolean' => "должно содержать логическое значение",
|
||||
'lengthBetween' => "должно содержать от %d до %d символов",
|
||||
'creditCard' => "должно быть номером кредитной карты",
|
||||
'lengthMin' => "должно содержать более %d символов",
|
||||
'lengthMax' => "должно содержать менее %d символов",
|
||||
'instanceOf' => "должно быть объектом класса '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "je povinná položka",
|
||||
'equals' => "musí byť rovnaký ako '%s'",
|
||||
'different' => "musí byť rôzny od '%s'",
|
||||
'accepted' => "musí byť akceptovaný",
|
||||
'numeric' => "musí byť číslo",
|
||||
'integer' => "musí byť celé číslo",
|
||||
'length' => "musí byť dlhý aspoň %d",
|
||||
'min' => "musí byť dlhý minimálne %s",
|
||||
'max' => "musí byť maximálne %s",
|
||||
'in' => "obsahuje nepovolenú hodnotu",
|
||||
'notIn' => "obsahuje nepovolenú hodnotu",
|
||||
'ip' => "nie je korektná IP adresa",
|
||||
'email' => "nie je korektný e-mail",
|
||||
'url' => "nie je URL",
|
||||
'urlActive' => "musí byť aktívna URL",
|
||||
'alpha' => "musí obsahovať len písmená a-z",
|
||||
'alphaNum' => "musí obsahovať len písmená a-z a/alebo čísla 0-9",
|
||||
'slug' => "musí obsahovať len písmená a-z, čísla 0-9, pomlčky alebo podtržítka",
|
||||
'regex' => "obsahuje nepovolené znaky",
|
||||
'date' => "nie je korektný formáť",
|
||||
'dateFormat' => "musí byť dátum formátu '%s'",
|
||||
'dateBefore' => "musí byť dátum pred '%s'",
|
||||
'dateAfter' => "musí byť dátum po '%s'",
|
||||
'contains' => "musí obsahovať %s",
|
||||
'boolean' => "musí byť pravdivostná hodnota (boolean)",
|
||||
'lengthBetween' => "musí byť %d až %d znakov dlhý",
|
||||
'creditCard' => "musí byť korektné číslo kreditnej karty",
|
||||
"lengthMin" => "musí byť aspoň %d znakov dlhý",
|
||||
"lengthMax" => "musí byť najviac %d znakov dlhý",
|
||||
"instanceOf" => "musí byť inštanciou '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "นั้นจำเป็นต้องมี",
|
||||
'equals' => "ต้องเหมือนกับ '%s'",
|
||||
'different' => "ต้องแตกต่างจาก '%s'",
|
||||
'accepted' => "ต้องถูกยอมรับ",
|
||||
'numeric' => "ต้องเป็นตัวเลข",
|
||||
'integer' => "ต้องเป็นตัวเลข integer",
|
||||
'length' => "ต้องมีความยาวมากกว่า %d",
|
||||
'min' => "ต้องมีอย่างน้อย %s",
|
||||
'max' => "ต้องไม่มากเกิน %s",
|
||||
'in' => "ประกอบด้วยค่าที่ไม่ถูกต้อง",
|
||||
'notIn' => "ประกอบด้วยค่าที่ไม่ถูกต้อง",
|
||||
'ip' => "ไม่ใช่ IP ที่ถูกต้อง",
|
||||
'email' => "ไม่ใช่อีเมลที่ถูกต้อง",
|
||||
'url' => "ไม่ใช่ลิงก์",
|
||||
'urlActive' => "ต้องไม่ใช่โดเมนที่ใช้งานอยู่",
|
||||
'alpha' => "ต้องมีแค่ตัวอักษร a-z",
|
||||
'alphaNum' => "ต้องมีแค่ตัวอักษร a-z และ/หรือ ตัวเลข 0-9",
|
||||
'slug' => "ต้องมีแค่ตัวอักษร a-z ตัวเลข 0-9 / และ _",
|
||||
'regex' => "มีตัวอักษรที่ไม่ถูกต้อง",
|
||||
'date' => "ไม่ใช่วันที่ที่ถูกต้อง",
|
||||
'dateFormat' => "ต้องเป็นวันที่ในรูปแบบ '%s'",
|
||||
'dateBefore' => "ต้องเป็นวันที่ก่อน '%s'",
|
||||
'dateAfter' => "ต้องเป็นวันที่หลัง '%s'",
|
||||
'contains' => "ต้องมี %s",
|
||||
'boolean' => "ต้องเป็น boolean",
|
||||
'lengthBetween' => "ต้องอยู่ระหว่าง %d ถึง %d ตัวอักษร",
|
||||
'creditCard' => "ต้องเป็นหมายเลขบัตรเครดิตที่ถูกต้อง",
|
||||
"lengthMin" => "ต้องมีมากกว่า %d ตัวอักษร",
|
||||
"lengthMax" => "ต้องมีน้อยกว่า %d ตัวอักษร",
|
||||
"instanceOf" => "ต้องเป็นส่วนหนึ่งของ '%s'"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "gerekli ",
|
||||
'equals' => "bununla aynı olmalı '%s'",
|
||||
'different' => "bundan değişik olmalı '%s'",
|
||||
'accepted' => "kabul edilebilir olmalı",
|
||||
'numeric' => "numerik olmalı",
|
||||
'integer' => "sayı olmalı",
|
||||
'length' => "en az %d adet uzunluğunda olmalı",
|
||||
'min' => "en az böyle olmalı %s",
|
||||
'max' => "bundan daha fazla olmalı %s",
|
||||
'in' => "geçersiz değer içeriyor",
|
||||
'notIn' => "geçersiz değer içeriyor",
|
||||
'ip' => "geçerli bir IP adresi değil",
|
||||
'email' => "geçerli bir eposta adresi değil",
|
||||
'url' => "bir URL değil",
|
||||
'urlActive' => "aktif bir alan adı olmalı",
|
||||
'alpha' => "sadece harf içermeli a-z",
|
||||
'alphaNum' => "sadece harf (a-z) ve/veya sayılar (0-9) içermeli",
|
||||
'slug' => "sadece harf (a-z), numbers sayılar (0-9), tire ve alt tire içermeli",
|
||||
'regex' => "geçersiz karakterler içeriyor",
|
||||
'date' => "geçerli bir karakter değil",
|
||||
'dateFormat' => "bu biçimde bir tarih olmalı '%s'",
|
||||
'dateBefore' => "bu tarihden önce olmalı '%s'",
|
||||
'dateAfter' => "bu tarihden sonra olmalı '%s'",
|
||||
'contains' => "bunu içermeli %s",
|
||||
'boolean' => "boolean olmalı",
|
||||
'lengthBetween' => "%d ve %d karakter arasında olmalı",
|
||||
'creditCard' => "geçerli bir kredi kartı numarası olmalı",
|
||||
"lengthMin" => "%d katakterden fazla içermeli",
|
||||
"lengthMax" => "%d karakterden az içermeli",
|
||||
"instanceOf" => "bunun bir örneği olmalı '%s'"
|
||||
);
|
||||
Vendored
+33
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "обов'язкове для заповнення",
|
||||
'equals' => "має містити '%s'",
|
||||
'different' => "має відрізнятися від '%s'",
|
||||
'accepted' => "має бути вказаним",
|
||||
'numeric' => "має містити числове значення",
|
||||
'integer' => "має бути числом",
|
||||
'length' => "має бути довшим, ніж %d",
|
||||
'min' => "має бути більше, ніж %s",
|
||||
'max' => "повинно бути менше, ніж %s",
|
||||
'in' => "містить невірне значення",
|
||||
'notIn' => "містить невірне значення",
|
||||
'ip' => "не є валідною IP адресою",
|
||||
'email' => "не є валідною email адресою",
|
||||
'url' => "не є посиланням",
|
||||
'urlActive' => "містить не активне посилання",
|
||||
'alpha' => "повинно містити тільки латинські символи",
|
||||
'alphaNum' => "повинно містити тільки латинські символи та/або цифри",
|
||||
'slug' => "повинно містити тільки латинські символи, цифри, тире і підкреслення",
|
||||
'regex' => "містить неприпустимі символи",
|
||||
'date' => "не є датою",
|
||||
'dateFormat' => "має містити дату наступного формату:%s",
|
||||
'dateBefore' => "має містити дату не пізнішу, ніж %s",
|
||||
'dateAfter' => "має містити дату не ранішу, ніж %s",
|
||||
'contains' => "має містити %s",
|
||||
'boolean' => "має містити логічне значення",
|
||||
'lengthBetween' => "має містити від %d в до %d символів",
|
||||
'creditCard' => "має бути номером кредитної картки",
|
||||
"lengthMin" => "має містити більше %d символів",
|
||||
"lengthMax" => "має містити менше %d символів"
|
||||
);
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "là bắt buộc",
|
||||
'equals' => "phải giống '%s'",
|
||||
'different' => "phải khác '%s'",
|
||||
'accepted' => "được chấp nhận",
|
||||
'numeric' => "phải là số",
|
||||
'integer' => "phải là số nguyên",
|
||||
'length' => "phải dài hơn %d",
|
||||
'min' => "ít nhất %s",
|
||||
'max' => "tối đa %s",
|
||||
'in' => "chứa giá trị không hợp lệ",
|
||||
'notIn' => "chứa giá trị không hợp lệ",
|
||||
'ip' => "địa chỉ IP không hợp lệ",
|
||||
'email' => "địa chỉ email không hợp lệ",
|
||||
'url' => "không phải là URL",
|
||||
'urlActive' => "Domain chưa được kích hoạt",
|
||||
'alpha' => "chỉ chứa các kí tự a-z",
|
||||
'alphaNum' => "chỉ chứa các kí tự a-z hoặc số 0-9",
|
||||
'slug' => "chỉ chứa các kí tự a-z, số 0-9, gạch nối và gạch dưới",
|
||||
'regex' => "chứa kí tự không hợp lệ",
|
||||
'date' => "thời gian hợp lệ",
|
||||
'dateFormat' => "thời gian nên được định dạng '%s'",
|
||||
'dateBefore' => "thời gian nên trước '%s'",
|
||||
'dateAfter' => "thời gian nên sau '%s'",
|
||||
'contains' => "phải chứa %s",
|
||||
'boolean' => "phải là boolean",
|
||||
'lengthBetween' => "phải từ %d đến %d kí tự",
|
||||
'creditCard' => "credit card không hợp lệ",
|
||||
"lengthMin" => "ít nhất %d kí tự",
|
||||
"lengthMax" => "tối đa %d kí tự",
|
||||
"instanceOf" => "phải là instance của '%s'"
|
||||
);
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "不能为空",
|
||||
'equals' => "必须和 '%s' 一致",
|
||||
'different' => "必须和 '%s' 不一致",
|
||||
'accepted' => "必须接受",
|
||||
'numeric' => "只能是数字",
|
||||
'integer' => "只能是整数",
|
||||
'length' => "长度必须大于 %d",
|
||||
'min' => "必须大于 %s",
|
||||
'max' => "必须小于 %s",
|
||||
'in' => "无效的值",
|
||||
'notIn' => "无效的值",
|
||||
'ip' => "无效IP地址",
|
||||
'email' => "无效邮箱地址",
|
||||
'url' => "无效的URL",
|
||||
'urlActive' => "必须是可用的域名",
|
||||
'alpha' => "只能包括英文字母(a-z)",
|
||||
'alphaNum' => "只能包括英文字母(a-z)和数字(0-9)",
|
||||
'slug' => "只能包括英文字母(a-z)、数字(0-9)、破折号和下划线",
|
||||
'regex' => "无效格式",
|
||||
'date' => "无效的日期",
|
||||
'dateFormat' => "日期的格式应该为 '%s'",
|
||||
'dateBefore' => "日期必须在 '%s' 之前",
|
||||
'dateAfter' => "日期必须在 '%s' 之后",
|
||||
'contains' => "必须包含 %s"
|
||||
);
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
return array(
|
||||
'required' => "不能為空",
|
||||
'equals' => "必須和 '%s' 一致",
|
||||
'different' => "必須和 '%s' 不一致",
|
||||
'accepted' => "必須接受",
|
||||
'numeric' => "只能是數字",
|
||||
'integer' => "只能是整數",
|
||||
'length' => "長度必須大於 %d",
|
||||
'min' => "必須大於 %s",
|
||||
'max' => "必須小於 %s",
|
||||
'in' => "無效的值",
|
||||
'notIn' => "無效的值",
|
||||
'ip' => "無效IP地址",
|
||||
'email' => "無效郵箱地址",
|
||||
'url' => "無效的URL",
|
||||
'urlActive' => "必須是可用的域名",
|
||||
'alpha' => "只能包括英文字母(a-z)",
|
||||
'alphaNum' => "只能包括英文字母(a-z)和數字(0-9)",
|
||||
'slug' => "只能包括英文字母(a-z)、數字(0-9)、破折號和下劃線",
|
||||
'regex' => "無效格式",
|
||||
'date' => "無效的日期",
|
||||
'dateFormat' => "日期的格式應該為 '%s'",
|
||||
'dateBefore' => "日期必須在 '%s' 之前",
|
||||
'dateAfter' => "日期必須在 '%s' 之後",
|
||||
'contains' => "必須包含 %s"
|
||||
);
|
||||
+1292
@@ -0,0 +1,1292 @@
|
||||
<?php
|
||||
namespace Valitron;
|
||||
|
||||
/**
|
||||
* Validation Class
|
||||
*
|
||||
* Validates input against certain criteria
|
||||
*
|
||||
* @package Valitron
|
||||
* @author Vance Lucas <vance@vancelucas.com>
|
||||
* @link http://www.vancelucas.com/
|
||||
*/
|
||||
class Validator
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
const ERROR_DEFAULT = 'Invalid';
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_fields = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_errors = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_validations = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $_labels = array();
|
||||
|
||||
/**
|
||||
* Contains all rules that are available to the current valitron instance.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_instanceRules = array();
|
||||
|
||||
/**
|
||||
* Contains all rule messages that are available to the current valitron
|
||||
* instance
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $_instanceRuleMessage = array();
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $_lang;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
protected static $_langDir;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $_rules = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected static $_ruleMessages = array();
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $validUrlPrefixes = array('http://', 'https://', 'ftp://');
|
||||
|
||||
/**
|
||||
* Setup validation
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $fields
|
||||
* @param string $lang
|
||||
* @param string $langDir
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function __construct($data = array(), $fields = array(), $lang = null, $langDir = null)
|
||||
{
|
||||
// Allows filtering of used input fields against optional second array of field names allowed
|
||||
// This is useful for limiting raw $_POST or $_GET data to only known fields
|
||||
$this->_fields = !empty($fields) ? array_intersect_key($data, array_flip($fields)) : $data;
|
||||
|
||||
// set lang in the follow order: constructor param, static::$_lang, default to en
|
||||
$lang = $lang ?: static::lang();
|
||||
|
||||
// set langDir in the follow order: constructor param, static::$_langDir, default to package lang dir
|
||||
$langDir = $langDir ?: static::langDir();
|
||||
|
||||
// Load language file in directory
|
||||
$langFile = rtrim($langDir, '/') . '/' . $lang . '.php';
|
||||
if (stream_resolve_include_path($langFile) ) {
|
||||
$langMessages = include $langFile;
|
||||
static::$_ruleMessages = array_merge(static::$_ruleMessages, $langMessages);
|
||||
} else {
|
||||
throw new \InvalidArgumentException("Fail to load language file '" . $langFile . "'");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/set language to use for validation messages
|
||||
*
|
||||
* @param string $lang
|
||||
* @return string
|
||||
*/
|
||||
public static function lang($lang = null)
|
||||
{
|
||||
if ($lang !== null) {
|
||||
static::$_lang = $lang;
|
||||
}
|
||||
|
||||
return static::$_lang ?: 'en';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get/set language file path
|
||||
*
|
||||
* @param string $dir
|
||||
* @return string
|
||||
*/
|
||||
public static function langDir($dir = null)
|
||||
{
|
||||
if ($dir !== null) {
|
||||
static::$_langDir = $dir;
|
||||
}
|
||||
|
||||
return static::$_langDir ?: dirname(dirname(__DIR__)) . '/lang';
|
||||
}
|
||||
|
||||
/**
|
||||
* Required field validator
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateRequired($field, $value, $params= array())
|
||||
{
|
||||
if (isset($params[0]) && (bool) $params[0]){
|
||||
$find = $this->getPart($this->_fields, explode('.', $field), true);
|
||||
return $find[1];
|
||||
}
|
||||
|
||||
if (is_null($value)) {
|
||||
return false;
|
||||
} elseif (is_string($value) && trim($value) === '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that two values match
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateEquals($field, $value, array $params)
|
||||
{
|
||||
$field2 = $params[0];
|
||||
|
||||
return isset($this->_fields[$field2]) && $value == $this->_fields[$field2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is different from another field
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateDifferent($field, $value, array $params)
|
||||
{
|
||||
$field2 = $params[0];
|
||||
|
||||
return isset($this->_fields[$field2]) && $value != $this->_fields[$field2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field was "accepted" (based on PHP's string evaluation rules)
|
||||
*
|
||||
* This validation rule implies the field is "required"
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateAccepted($field, $value)
|
||||
{
|
||||
$acceptable = array('yes', 'on', 1, '1', true);
|
||||
|
||||
return $this->validateRequired($field, $value) && in_array($value, $acceptable, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is an array
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateArray($field, $value)
|
||||
{
|
||||
return is_array($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is numeric
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateNumeric($field, $value)
|
||||
{
|
||||
return is_numeric($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is an integer
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateInteger($field, $value, $params)
|
||||
{
|
||||
if (isset($params[0]) && (bool) $params[0]){
|
||||
//strict mode
|
||||
return preg_match('/^-?([0-9])+$/i', $value);
|
||||
}
|
||||
|
||||
return filter_var($value, \FILTER_VALIDATE_INT) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the length of a string
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateLength($field, $value, $params)
|
||||
{
|
||||
$length = $this->stringLength($value);
|
||||
// Length between
|
||||
if (isset($params[1])) {
|
||||
return $length >= $params[0] && $length <= $params[1];
|
||||
}
|
||||
// Length same
|
||||
return ($length !== false) && $length == $params[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the length of a string (between)
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @return boolean
|
||||
*/
|
||||
protected function validateLengthBetween($field, $value, $params)
|
||||
{
|
||||
$length = $this->stringLength($value);
|
||||
|
||||
return ($length !== false) && $length >= $params[0] && $length <= $params[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the length of a string (min)
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function validateLengthMin($field, $value, $params)
|
||||
{
|
||||
$length = $this->stringLength($value);
|
||||
|
||||
return ($length !== false) && $length >= $params[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the length of a string (max)
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
protected function validateLengthMax($field, $value, $params)
|
||||
{
|
||||
$length = $this->stringLength($value);
|
||||
|
||||
return ($length !== false) && $length <= $params[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of a string
|
||||
*
|
||||
* @param string $value
|
||||
* @return int|false
|
||||
*/
|
||||
protected function stringLength($value)
|
||||
{
|
||||
if (!is_string($value)) {
|
||||
return false;
|
||||
} elseif (function_exists('mb_strlen')) {
|
||||
return mb_strlen($value);
|
||||
}
|
||||
|
||||
return strlen($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the size of a field is greater than a minimum value.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateMin($field, $value, $params)
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
return false;
|
||||
} elseif (function_exists('bccomp')) {
|
||||
return !(bccomp($params[0], $value, 14) === 1);
|
||||
} else {
|
||||
return $params[0] <= $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the size of a field is less than a maximum value
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateMax($field, $value, $params)
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
return false;
|
||||
} elseif (function_exists('bccomp')) {
|
||||
return !(bccomp($value, $params[0], 14) === 1);
|
||||
} else {
|
||||
return $params[0] >= $value;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the size of a field is between min and max values
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateBetween($field, $value, $params)
|
||||
{
|
||||
if (!is_numeric($value)) {
|
||||
return false;
|
||||
}
|
||||
if (!isset($params[0]) || !is_array($params[0]) || count($params[0]) !== 2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
list($min, $max) = $params[0];
|
||||
|
||||
return $this->validateMin($field, $value, array($min)) && $this->validateMax($field, $value, array($max));
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a field is contained within a list of values
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateIn($field, $value, $params)
|
||||
{
|
||||
$isAssoc = array_values($params[0]) !== $params[0];
|
||||
if ($isAssoc) {
|
||||
$params[0] = array_keys($params[0]);
|
||||
}
|
||||
|
||||
$strict = false;
|
||||
if (isset($params[1])) {
|
||||
$strict = $params[1];
|
||||
}
|
||||
|
||||
return in_array($value, $params[0], $strict);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a field is not contained within a list of values
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateNotIn($field, $value, $params)
|
||||
{
|
||||
return !$this->validateIn($field, $value, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a field contains a given string
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateContains($field, $value, $params)
|
||||
{
|
||||
if (!isset($params[0])) {
|
||||
return false;
|
||||
}
|
||||
if (!is_string($params[0]) || !is_string($value)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$strict = true;
|
||||
if (isset($params[1])) {
|
||||
$strict = (bool) $params[1];
|
||||
}
|
||||
|
||||
$isContains = false;
|
||||
if ($strict) {
|
||||
if (function_exists('mb_strpos')) {
|
||||
$isContains = mb_strpos($value, $params[0]) !== false;
|
||||
} else {
|
||||
$isContains = strpos($value, $params[0]) !== false;
|
||||
}
|
||||
} else {
|
||||
if (function_exists('mb_stripos')) {
|
||||
$isContains = mb_stripos($value, $params[0]) !== false;
|
||||
} else {
|
||||
$isContains = stripos($value, $params[0]) !== false;
|
||||
}
|
||||
}
|
||||
return $isContains;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is a valid IP address
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateIp($field, $value)
|
||||
{
|
||||
return filter_var($value, \FILTER_VALIDATE_IP) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is a valid e-mail address
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateEmail($field, $value)
|
||||
{
|
||||
return filter_var($value, \FILTER_VALIDATE_EMAIL) !== false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is a valid URL by syntax
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateUrl($field, $value)
|
||||
{
|
||||
foreach ($this->validUrlPrefixes as $prefix) {
|
||||
if (strpos($value, $prefix) !== false) {
|
||||
return filter_var($value, \FILTER_VALIDATE_URL) !== false;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is an active URL by verifying DNS record
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateUrlActive($field, $value)
|
||||
{
|
||||
foreach ($this->validUrlPrefixes as $prefix) {
|
||||
if (strpos($value, $prefix) !== false) {
|
||||
$host = parse_url(strtolower($value), PHP_URL_HOST);
|
||||
|
||||
return checkdnsrr($host, 'A') || checkdnsrr($host, 'AAAA') || checkdnsrr($host, 'CNAME');
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field contains only alphabetic characters
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateAlpha($field, $value)
|
||||
{
|
||||
return preg_match('/^([a-z])+$/i', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field contains only alpha-numeric characters
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateAlphaNum($field, $value)
|
||||
{
|
||||
return preg_match('/^([a-z0-9])+$/i', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field contains only alpha-numeric characters, dashes, and underscores
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateSlug($field, $value)
|
||||
{
|
||||
if(is_array($value)) {
|
||||
return false;
|
||||
}
|
||||
return preg_match('/^([-a-z0-9_-])+$/i', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field passes a regular expression check
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateRegex($field, $value, $params)
|
||||
{
|
||||
return preg_match($params[0], $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field is a valid date
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateDate($field, $value)
|
||||
{
|
||||
$isDate = false;
|
||||
if ($value instanceof \DateTime) {
|
||||
$isDate = true;
|
||||
} else {
|
||||
$isDate = strtotime($value) !== false;
|
||||
}
|
||||
|
||||
return $isDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field matches a date format
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateDateFormat($field, $value, $params)
|
||||
{
|
||||
$parsed = date_parse_from_format($params[0], $value);
|
||||
|
||||
return $parsed['error_count'] === 0 && $parsed['warning_count'] === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the date is before a given date
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateDateBefore($field, $value, $params)
|
||||
{
|
||||
$vtime = ($value instanceof \DateTime) ? $value->getTimestamp() : strtotime($value);
|
||||
$ptime = ($params[0] instanceof \DateTime) ? $params[0]->getTimestamp() : strtotime($params[0]);
|
||||
|
||||
return $vtime < $ptime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate the date is after a given date
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @internal param array $fields
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateDateAfter($field, $value, $params)
|
||||
{
|
||||
$vtime = ($value instanceof \DateTime) ? $value->getTimestamp() : strtotime($value);
|
||||
$ptime = ($params[0] instanceof \DateTime) ? $params[0]->getTimestamp() : strtotime($params[0]);
|
||||
|
||||
return $vtime > $ptime;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field contains a boolean.
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateBoolean($field, $value)
|
||||
{
|
||||
return is_bool($value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate that a field contains a valid credit card
|
||||
* optionally filtered by an array
|
||||
*
|
||||
* @param string $field
|
||||
* @param mixed $value
|
||||
* @param array $params
|
||||
* @return bool
|
||||
*/
|
||||
protected function validateCreditCard($field, $value, $params)
|
||||
{
|
||||
/**
|
||||
* I there has been an array of valid cards supplied, or the name of the users card
|
||||
* or the name and an array of valid cards
|
||||
*/
|
||||
if (!empty($params)) {
|
||||
/**
|
||||
* array of valid cards
|
||||
*/
|
||||
if (is_array($params[0])) {
|
||||
$cards = $params[0];
|
||||
} elseif (is_string($params[0])) {
|
||||
$cardType = $params[0];
|
||||
if (isset($params[1]) && is_array($params[1])) {
|
||||
$cards = $params[1];
|
||||
if (!in_array($cardType, $cards)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Luhn algorithm
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
$numberIsValid = function () use ($value) {
|
||||
$number = preg_replace('/[^0-9]+/', '', $value);
|
||||
$sum = 0;
|
||||
|
||||
$strlen = strlen($number);
|
||||
if ($strlen < 13) {
|
||||
return false;
|
||||
}
|
||||
for ($i = 0; $i < $strlen; $i++) {
|
||||
$digit = (int) substr($number, $strlen - $i - 1, 1);
|
||||
if ($i % 2 == 1) {
|
||||
$sub_total = $digit * 2;
|
||||
if ($sub_total > 9) {
|
||||
$sub_total = ($sub_total - 10) + 1;
|
||||
}
|
||||
} else {
|
||||
$sub_total = $digit;
|
||||
}
|
||||
$sum += $sub_total;
|
||||
}
|
||||
if ($sum > 0 && $sum % 10 == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
if ($numberIsValid()) {
|
||||
if (!isset($cards)) {
|
||||
return true;
|
||||
} else {
|
||||
$cardRegex = array(
|
||||
'visa' => '#^4[0-9]{12}(?:[0-9]{3})?$#',
|
||||
'mastercard' => '#^(5[1-5]|2[2-7])[0-9]{14}$#',
|
||||
'amex' => '#^3[47][0-9]{13}$#',
|
||||
'dinersclub' => '#^3(?:0[0-5]|[68][0-9])[0-9]{11}$#',
|
||||
'discover' => '#^6(?:011|5[0-9]{2})[0-9]{12}$#',
|
||||
);
|
||||
|
||||
if (isset($cardType)) {
|
||||
// if we don't have any valid cards specified and the card we've been given isn't in our regex array
|
||||
if (!isset($cards) && !in_array($cardType, array_keys($cardRegex))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// we only need to test against one card type
|
||||
return (preg_match($cardRegex[$cardType], $value) === 1);
|
||||
|
||||
} elseif (isset($cards)) {
|
||||
// if we have cards, check our users card against only the ones we have
|
||||
foreach ($cards as $card) {
|
||||
if (in_array($card, array_keys($cardRegex))) {
|
||||
// if the card is valid, we want to stop looping
|
||||
if (preg_match($cardRegex[$card], $value) === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// loop through every card
|
||||
foreach ($cardRegex as $regex) {
|
||||
// until we find a valid one
|
||||
if (preg_match($regex, $value) === 1) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if we've got this far, the card has passed no validation so it's invalid!
|
||||
return false;
|
||||
}
|
||||
|
||||
protected function validateInstanceOf($field, $value, $params)
|
||||
{
|
||||
$isInstanceOf = false;
|
||||
if (is_object($value)) {
|
||||
if (is_object($params[0]) && $value instanceof $params[0]) {
|
||||
$isInstanceOf = true;
|
||||
}
|
||||
if (get_class($value) === $params[0]) {
|
||||
$isInstanceOf = true;
|
||||
}
|
||||
}
|
||||
if (is_string($value)) {
|
||||
if (is_string($params[0]) && get_class($value) === $params[0]) {
|
||||
$isInstanceOf = true;
|
||||
}
|
||||
}
|
||||
|
||||
return $isInstanceOf;
|
||||
}
|
||||
|
||||
//Validate optional field
|
||||
protected function validateOptional($field, $value, $params) {
|
||||
//Always return true
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of fields and data
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function data()
|
||||
{
|
||||
return $this->_fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get array of error messages
|
||||
*
|
||||
* @param null|string $field
|
||||
* @return array|bool
|
||||
*/
|
||||
public function errors($field = null)
|
||||
{
|
||||
if ($field !== null) {
|
||||
return isset($this->_errors[$field]) ? $this->_errors[$field] : false;
|
||||
}
|
||||
|
||||
return $this->_errors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add an error to error messages array
|
||||
*
|
||||
* @param string $field
|
||||
* @param string $msg
|
||||
* @param array $params
|
||||
*/
|
||||
public function error($field, $msg, array $params = array())
|
||||
{
|
||||
$msg = $this->checkAndSetLabel($field, $msg, $params);
|
||||
|
||||
$values = array();
|
||||
// Printed values need to be in string format
|
||||
foreach ($params as $param) {
|
||||
if (is_array($param)) {
|
||||
$param = "['" . implode("', '", $param) . "']";
|
||||
}
|
||||
if ($param instanceof \DateTime) {
|
||||
$param = $param->format('Y-m-d');
|
||||
} else {
|
||||
if (is_object($param)) {
|
||||
$param = get_class($param);
|
||||
}
|
||||
}
|
||||
// Use custom label instead of field name if set
|
||||
if (is_string($params[0])) {
|
||||
if (isset($this->_labels[$param])) {
|
||||
$param = $this->_labels[$param];
|
||||
}
|
||||
}
|
||||
$values[] = $param;
|
||||
}
|
||||
|
||||
$this->_errors[$field][] = vsprintf($msg, $values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify validation message to use for error for the last validation rule
|
||||
*
|
||||
* @param string $msg
|
||||
* @return $this
|
||||
*/
|
||||
public function message($msg)
|
||||
{
|
||||
$this->_validations[count($this->_validations) - 1]['message'] = $msg;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset object properties
|
||||
*/
|
||||
public function reset()
|
||||
{
|
||||
$this->_fields = array();
|
||||
$this->_errors = array();
|
||||
$this->_validations = array();
|
||||
$this->_labels = array();
|
||||
}
|
||||
|
||||
protected function getPart($data, $identifiers, $allow_empty = false)
|
||||
{
|
||||
// Catches the case where the field is an array of discrete values
|
||||
if (is_array($identifiers) && count($identifiers) === 0) {
|
||||
return array($data, false);
|
||||
}
|
||||
// Catches the case where the data isn't an array or object
|
||||
if (is_scalar($data)) {
|
||||
return array(NULL, false);
|
||||
}
|
||||
$identifier = array_shift($identifiers);
|
||||
// Glob match
|
||||
if ($identifier === '*') {
|
||||
$values = array();
|
||||
foreach ($data as $row) {
|
||||
list($value, $multiple) = $this->getPart($row, $identifiers, $allow_empty);
|
||||
if ($multiple) {
|
||||
$values = array_merge($values, $value);
|
||||
} else {
|
||||
$values[] = $value;
|
||||
}
|
||||
}
|
||||
return array($values, true);
|
||||
}
|
||||
// Dead end, abort
|
||||
elseif ($identifier === NULL || ! isset($data[$identifier])) {
|
||||
if ($allow_empty){
|
||||
//when empty values are allowed, we only care if the key exists
|
||||
return array(null, array_key_exists($identifier, $data));
|
||||
}
|
||||
return array(null, false);
|
||||
}
|
||||
// Match array element
|
||||
elseif (count($identifiers) === 0) {
|
||||
if ($allow_empty){
|
||||
//when empty values are allowed, we only care if the key exists
|
||||
return array(null, array_key_exists($identifier, $data));
|
||||
}
|
||||
return array($data[$identifier], false);
|
||||
}
|
||||
// We need to go deeper
|
||||
else {
|
||||
return $this->getPart($data[$identifier], $identifiers, $allow_empty);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Run validations and return boolean result
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function validate()
|
||||
{
|
||||
foreach ($this->_validations as $v) {
|
||||
foreach ($v['fields'] as $field) {
|
||||
list($values, $multiple) = $this->getPart($this->_fields, explode('.', $field));
|
||||
|
||||
// Don't validate if the field is not required and the value is empty
|
||||
if ($this->hasRule('optional', $field) && isset($values)) {
|
||||
//Continue with execution below if statement
|
||||
} elseif (
|
||||
$v['rule'] !== 'required' && !$this->hasRule('required', $field) &&
|
||||
$v['rule'] !== 'accepted' &&
|
||||
(! isset($values) || $values === '' || ($multiple && count($values) == 0))
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Callback is user-specified or assumed method on class
|
||||
$errors = $this->getRules();
|
||||
if (isset($errors[$v['rule']])) {
|
||||
$callback = $errors[$v['rule']];
|
||||
} else {
|
||||
$callback = array($this, 'validate' . ucfirst($v['rule']));
|
||||
}
|
||||
|
||||
if (!$multiple) {
|
||||
$values = array($values);
|
||||
}
|
||||
|
||||
$result = true;
|
||||
foreach ($values as $value) {
|
||||
$result = $result && call_user_func($callback, $field, $value, $v['params'], $this->_fields);
|
||||
}
|
||||
|
||||
if (!$result) {
|
||||
$this->error($field, $v['message'], $v['params']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return count($this->errors()) === 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all rule callbacks, the static and instance ones.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRules()
|
||||
{
|
||||
return array_merge($this->_instanceRules, static::$_rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all rule message, the static and instance ones.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
protected function getRuleMessages()
|
||||
{
|
||||
return array_merge($this->_instanceRuleMessage, static::$_ruleMessages);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine whether a field is being validated by the given rule.
|
||||
*
|
||||
* @param string $name The name of the rule
|
||||
* @param string $field The name of the field
|
||||
* @return boolean
|
||||
*/
|
||||
|
||||
protected function hasRule($name, $field)
|
||||
{
|
||||
foreach ($this->_validations as $validation) {
|
||||
if ($validation['rule'] == $name) {
|
||||
if (in_array($field, $validation['fields'])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
protected static function assertRuleCallback($callback)
|
||||
{
|
||||
if (!is_callable($callback)) {
|
||||
throw new \InvalidArgumentException('Second argument must be a valid callback. Given argument was not callable.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adds a new validation rule callback that is tied to the current
|
||||
* instance only.
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $callback
|
||||
* @param string $message
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function addInstanceRule($name, $callback, $message = null)
|
||||
{
|
||||
static::assertRuleCallback($callback);
|
||||
|
||||
$this->_instanceRules[$name] = $callback;
|
||||
$this->_instanceRuleMessage[$name] = $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register new validation rule callback
|
||||
*
|
||||
* @param string $name
|
||||
* @param mixed $callback
|
||||
* @param string $message
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public static function addRule($name, $callback, $message = null)
|
||||
{
|
||||
if ($message === null)
|
||||
{
|
||||
$message = static::ERROR_DEFAULT;
|
||||
}
|
||||
|
||||
static::assertRuleCallback($callback);
|
||||
|
||||
static::$_rules[$name] = $callback;
|
||||
static::$_ruleMessages[$name] = $message;
|
||||
}
|
||||
|
||||
public function getUniqueRuleName($fields)
|
||||
{
|
||||
if (is_array($fields))
|
||||
{
|
||||
$fields = implode("_", $fields);
|
||||
}
|
||||
|
||||
$orgName = "{$fields}_rule";
|
||||
$name = $orgName;
|
||||
$rules = $this->getRules();
|
||||
while (isset($rules[$name]))
|
||||
{
|
||||
$name = $orgName . "_" . rand(0, 10000);
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if either a valdiator with the given name has been
|
||||
* registered or there is a default validator by that name.
|
||||
*
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function hasValidator($name)
|
||||
{
|
||||
$rules = $this->getRules();
|
||||
return method_exists($this, "validate" . ucfirst($name))
|
||||
|| isset($rules[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to add a single validation rule
|
||||
*
|
||||
* @param string|callback $rule
|
||||
* @param array|string $fields
|
||||
* @return $this
|
||||
* @throws \InvalidArgumentException
|
||||
*/
|
||||
public function rule($rule, $fields)
|
||||
{
|
||||
// Get any other arguments passed to function
|
||||
$params = array_slice(func_get_args(), 2);
|
||||
|
||||
if (is_callable($rule)
|
||||
&& !(is_string($rule) && $this->hasValidator($rule)))
|
||||
{
|
||||
$name = $this->getUniqueRuleName($fields);
|
||||
$msg = isset($params[0]) ? $params[0] : null;
|
||||
$this->addInstanceRule($name, $rule, $msg);
|
||||
$rule = $name;
|
||||
}
|
||||
|
||||
$errors = $this->getRules();
|
||||
if (!isset($errors[$rule])) {
|
||||
$ruleMethod = 'validate' . ucfirst($rule);
|
||||
if (!method_exists($this, $ruleMethod)) {
|
||||
throw new \InvalidArgumentException("Rule '" . $rule . "' has not been registered with " . __CLASS__ . "::addRule().");
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure rule has an accompanying message
|
||||
$msgs = $this->getRuleMessages();
|
||||
$message = isset($msgs[$rule]) ? $msgs[$rule] : self::ERROR_DEFAULT;
|
||||
|
||||
// Ensure message contains field label
|
||||
if (function_exists('mb_strpos')) {
|
||||
$notContains = mb_strpos($message, '{field}') === false;
|
||||
} else {
|
||||
$notContains = strpos($message, '{field}') === false;
|
||||
}
|
||||
if ($notContains) {
|
||||
$message = '{field} ' . $message;
|
||||
}
|
||||
|
||||
$this->_validations[] = array(
|
||||
'rule' => $rule,
|
||||
'fields' => (array) $fields,
|
||||
'params' => (array) $params,
|
||||
'message' => $message
|
||||
);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $value
|
||||
* @internal param array $labels
|
||||
* @return $this
|
||||
*/
|
||||
public function label($value)
|
||||
{
|
||||
$lastRules = $this->_validations[count($this->_validations) - 1]['fields'];
|
||||
$this->labels(array($lastRules[0] => $value));
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $labels
|
||||
* @return $this
|
||||
*/
|
||||
public function labels($labels = array())
|
||||
{
|
||||
$this->_labels = array_merge($this->_labels, $labels);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $field
|
||||
* @param string $msg
|
||||
* @param array $params
|
||||
* @return array
|
||||
*/
|
||||
protected function checkAndSetLabel($field, $msg, $params)
|
||||
{
|
||||
if (isset($this->_labels[$field])) {
|
||||
$msg = str_replace('{field}', $this->_labels[$field], $msg);
|
||||
|
||||
if (is_array($params)) {
|
||||
$i = 1;
|
||||
foreach ($params as $k => $v) {
|
||||
$tag = '{field'. $i .'}';
|
||||
$label = isset($params[$k]) && (is_numeric($params[$k]) || is_string($params[$k])) && isset($this->_labels[$params[$k]]) ? $this->_labels[$params[$k]] : $tag;
|
||||
$msg = str_replace($tag, $label, $msg);
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$msg = str_replace('{field}', ucwords(str_replace('_', ' ', $field)), $msg);
|
||||
}
|
||||
|
||||
return $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to add multiple validation rules with an array
|
||||
*
|
||||
* @param array $rules
|
||||
*/
|
||||
public function rules($rules)
|
||||
{
|
||||
foreach ($rules as $ruleType => $params) {
|
||||
if (is_array($params)) {
|
||||
foreach ($params as $innerParams) {
|
||||
if (! is_array($innerParams)){
|
||||
$innerParams = (array) $innerParams;
|
||||
}
|
||||
array_unshift($innerParams, $ruleType);
|
||||
call_user_func_array(array($this, 'rule'), $innerParams);
|
||||
}
|
||||
} else {
|
||||
$this->rule($ruleType, $params);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace data on cloned instance
|
||||
*
|
||||
* @param array $data
|
||||
* @param array $fields
|
||||
* @return \Valitron\Validator
|
||||
*/
|
||||
public function withData($data, $fields = array())
|
||||
{
|
||||
$clone = clone $this;
|
||||
$clone->_fields = !empty($fields) ? array_intersect_key($data, array_flip($fields)) : $data;
|
||||
$clone->_errors = array();
|
||||
return $clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to add validation rule(s) by field
|
||||
*
|
||||
* @param string field_name
|
||||
* @param array $rules
|
||||
*/
|
||||
public function mapFieldRules($field_name, $rules){
|
||||
$me = $this;
|
||||
|
||||
array_map(function($rule) use($field_name, $me){
|
||||
|
||||
//rule must be an array
|
||||
$rule = (array)$rule;
|
||||
|
||||
//First element is the name of the rule
|
||||
$rule_name = array_shift($rule);
|
||||
|
||||
//find a custom message, if any
|
||||
$message = null;
|
||||
if (isset($rule['message'])){
|
||||
$message = $rule['message'];
|
||||
unset($rule['message']);
|
||||
}
|
||||
//Add the field and additional parameters to the rule
|
||||
$added = call_user_func_array(array($me, 'rule'), array_merge(array($rule_name, $field_name), $rule));
|
||||
if (! empty($message)){
|
||||
$added->message($message);
|
||||
}
|
||||
}, (array) $rules);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convenience method to add validation rule(s) for multiple fields
|
||||
*
|
||||
* @param array $rules
|
||||
*/
|
||||
public function mapFieldsRules($rules){
|
||||
$me = $this;
|
||||
array_map(function($field_name) use($rules, $me){
|
||||
$me->mapFieldRules($field_name, $rules[$field_name]);
|
||||
}, array_keys($rules));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user