106 Commits

Author SHA1 Message Date
Tom Breese
d3171b8872 Adding examples for regular and alternate syntax to docs 2018-10-13 12:57:50 -04:00
misantron
ee2ed6c3b9 Change validation rule to 'subset', document and translation fixes 2018-09-23 00:53:19 +03:00
misantron
c52612f86c Tests code style fixes 2018-09-22 17:00:34 +03:00
misantron
f70e27af56 Merge remote master branch 2018-09-22 16:35:15 +03:00
Vance Lucas
14702f00d3
Merge pull request #261 from rauwebieten/master
ipv4, ipv6 and ascii rules
2018-09-11 11:59:23 -05:00
Willem Wollebrants
aaf543517d filter out non-required array parts. Fixes #262 2018-08-22 12:54:14 +02:00
peterkinamo
e5ae2c9a5f ipv4 and ipv6 rule and tests added 2018-08-03 13:02:21 +02:00
peterkinamo
971da213a3 Ascii rule added
Ascii unit test added
2018-08-03 12:28:23 +02:00
misantron
c4be38862b Validation fixes 2018-04-20 21:00:34 +03:00
peter279k
9ec218f031 Fix count() countable error message in php7.2 2018-04-14 16:56:19 +08:00
Willem Wollebrants
b6589e85ea
Strict integer rule
Fixed strict integer rule and added more integer unit tests
2018-03-29 20:57:51 +02:00
misantron
48dcdc7248 Merge remote-tracking branch 'remotes/upstream/master' into validators-patch 2018-03-05 22:21:09 +03:00
Julius Ijie
6837c9dfab Added option to stop validation when a rule is failed 2018-02-23 15:25:35 +01:00
Willem Wollebrants
8abb9b7220
Merge pull request #237 from mangopeaches/nested-equals-different
added nested array support for validateEquals and validateDifferent
2018-02-07 17:35:13 +01:00
Tom Breese
19a1e123bd updating tests for 5.3 compatible arrays 2018-02-06 23:10:20 -05:00
Tom Breese
32dec57f69 adding nested different both unser required test 2018-02-06 23:05:25 -05:00
Tom Breese
06d1740c32 adding tests for nulls/not set values for nested and not nested equals and different methods 2018-02-06 23:02:03 -05:00
Tom Breese
7c94b2ae5a added support for nested arrays in validateEquals and validateDifferent validation methods 2018-02-04 13:24:47 -05:00
Willem Wollebrants
7dcc8a5089 add test for new emailDNS validator 2018-01-31 16:19:05 +01:00
Willem Wollebrants
d1563d520f Make sure testRequiredAllowEmpty() tests 2 different usages for required rule 2017-12-02 21:28:13 +01:00
Gabriel Caruso
14a467ba24 Use PHPUnit\Framework\TestCase instead of PHPUnit_Framework_TestCase 2017-11-11 02:28:10 -02:00
misantron
d9a466b833 Array contains and unique validators added, code style fixes 2017-10-26 23:09:45 +03:00
Dennis Meckel
eb436a382f Fixed strict integer rule and added more integer unit tests 2017-10-13 19:39:59 +02:00
Willem Wollebrants
4cc030c68a validate fields that are required, but may have empty or null values. #208 2017-08-28 21:52:21 +02:00
Willem Wollebrants
6350cf8cb0 Test for pr #212 2017-08-27 13:34:43 +02:00
Willem Wollebrants
b29fbc50ff Make sure error messages get tested too 2017-07-18 20:54:29 +02:00
Willem Wollebrants
86cdecf193 Always run 'accepted' validation (#101) 2017-07-06 11:21:27 +02:00
Willem Wollebrants
ec77d601ad Handle malformed bulk rules (#204) 2017-07-06 11:03:04 +02:00
Willem Wollebrants
a6cf3a8c86 Merge pull request #201 from auroraeosrose/foreachbug
Check if the value in getParts is non-scalar to prevent "Invalid argument to foreach" error
2017-06-23 23:38:17 +02:00
Elizabeth M Smith
66464f4c51 test for the bug 2017-06-23 14:05:47 -04:00
Elizabeth M Smith
4896ade387 really? 5.3 support? ewww 2017-06-23 13:50:49 -04:00
Elizabeth M Smith
05b5c40515 test for the change 2017-06-23 13:43:15 -04:00
Willem Wollebrants
1942e53a5c Remove unneeded test testIntegerWithMaxValidation 2017-02-21 21:12:27 +01:00
Willem Wollebrants
28d954817b Use an optional parameter to make validateInteger more strict 2017-02-21 21:11:14 +01:00
notona
cb1ecb12e6 fix for test codes 2017-02-20 12:32:37 +09:00
notona
bc035a4a95 add more tests 2017-02-20 12:28:16 +09:00
notona
7c990e39ef fix integer validation process 2017-02-20 12:18:18 +09:00
Willem Wollebrants
c8895683f7 mapFieldRules 2017-02-09 20:39:17 +01:00
Willem Wollebrants
f8290a8c59 Fix bug where Validator::withData would also erase all rules 2016-12-09 11:44:39 +01:00
Andy Snell
f9dd486b5d
Update MasterCard BIN Range
Updates the credit card validator regular expression for the MasterCard brand to also match 16-digit card numbers starting with 22 - 27.  Additionally, updates the unit test for credit cards with two published test cards in the new BIN range.

Additional information on the BIN range update can be found at: https://www.mastercard.us/en-us/issuers/get-support/2-series-bin-expansion.html
2016-12-05 00:09:39 -05:00
Matteo Kloiber
a6be7e2dd0 Validator::rule now accepts any kind of callback
This has been achieved by making sure that the rule is neither
a "native" Validator rule (e.g. there is a validate{$CamleCaseName}
method) nor it has been registered.

If both conditions are met, the rule (even if it is a string)
will be accepted and used.

Tests for this case have also been added.
2016-11-06 01:46:35 +01:00
Matteo Kloiber
74a882969e Indent fixed 2016-11-06 01:46:28 +01:00
Matteo Kloiber
7a5fd66990 Validator::rule now supports closures
Validator::rule now allows the rule to be a closure.
This allows us to add an anonymous rule that is only
valid for the specified field(s):

$someObject = new MyObject();
$v->rule(function($field, $value) use ($someObject)
    return $value === $someObject->someState();
}, ["shared_secret", "other"])
    ->label("invalid state!");

This is especially useful if you have either a) have
a rule which you are not likely to be reusing or b)
you need access to some object which cannot be easily
connstructed (because it requires IO access, etc).

Either way, this is really only convenience method
because it saves you a call to Validator::addInstanceRule.

Internally, it does exactly that: it 1) determines a valid
rule name, 2) calls addInstanceRule() with the name
determined in 1) and the Closure, and then 3) replaces
the $rule parameter (which is the Closure object) by
the name of the rule.

1) is determined like this: if multiple parameters were
given, they are joined together into one string glued
with a underscore. '_rule' is then appended so that
the name becomes all_params_rule. If the name is already
used by any other rule, it will append up to 5
pseudo-random digits to the rule. In the unlikely event
that this rule is also used, step 1) will be repeated
until a unique rule name is found.
2016-11-06 01:46:25 +01:00
Matteo Kloiber
df78fe188c Added support for instance rules
Instance rules are not shared among other validator
objects (thus they are not static). This is useful
if you have a rule you do not want your other validators
to use (because it is very special to this validator).

The parameter given to addInstanceRule is identically to
addRule:

    public function addInstanceRule(string $name, callable $callback [, string message])

Instead of appending to the static variables $_rules, and
$_ruleMessages, it now appends to $_instanceRules and
$_instanceRuleMessages.

A new getter for the rules and ruleMessage has also been added:

    public array getRules()
    public array getRuleMessages()

All existing code has been updated to use getRules(), and
getRuleMessages() instead of $_rules, and $_ruleMessages.
2016-11-06 01:46:17 +01:00
Willem Wollebrants
94317636d9 Added withData method for immutable reusability 2016-08-17 21:44:17 +02:00
misantron
d47c6206ed Change contains validator default mode to strict 2016-05-21 20:48:01 +03:00
misantron
a89c0972c1 Contains validator update, between validator added 2016-03-26 00:55:08 +03:00
Willem Wollebrants
9afa605dc3 Add tests for 'optional' rule 2016-02-22 12:13:02 +01:00
USAMI Kenta
96221ea4d3 Add type check for between comparison
Return 0 if $value is not numeric value
2015-11-20 16:57:15 +09:00
USAMI Kenta
28254e76c2 Add type check for stringLength
Return 0 if $value is not string
2015-11-20 16:55:56 +09:00