412 Commits

Author SHA1 Message Date
misantron
11139b8534 Code style changes and fixes 2016-12-26 16:28:59 +03:00
Willem Wollebrants
28d5a5a0a3 Merge pull request #173 from EgorGruzdev/master
Fix doctype declaration for rule method. Allows both array and string for $field parameter
2016-12-14 09:47:35 +01:00
Egor Gruzdev
5181664c79 for PhpStorm validation 2016-12-14 10:40:14 +02:00
Willem Wollebrants
d9b1548c39 Merge pull request #171 from vlucas/withDataBugfix
With data bugfix
v1.3.1
2016-12-09 11:59:35 +01:00
Willem Wollebrants
768a26c7f4 Add note about re-usability to readme 2016-12-09 11:50:13 +01:00
Willem Wollebrants
f8290a8c59 Fix bug where Validator::withData would also erase all rules 2016-12-09 11:44:39 +01:00
Vance Lucas
399004d172 Merge pull request #169 from andysnell/update-mastercard-bin-range
Update MasterCard BIN Range
2016-12-06 10:04:05 -06: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
Willem Wollebrants
ce8e9a4a39 Merge pull request #167 from shin1x1/fix-wrong-return-type
Fix wrong @return in Doc Comments
v1.3.0
2016-11-15 13:32:32 +01:00
shin1x1
4f0f78ecfb Fix wrong @return 2016-11-15 18:06:16 +09:00
Willem Wollebrants
633c9ff57f Merge pull request #166 from Matt3o12/addTmpRule
Add anonymous and instance rules
2016-11-13 13:13:10 +01: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
ebbeca46af Updated README.md 2016-11-06 01:46:34 +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
6200b45304 Merge pull request #161 from vlucas/withdata
Added withData method for immutable reusability
2016-08-17 21:48:04 +02:00
Willem Wollebrants
94317636d9 Added withData method for immutable reusability 2016-08-17 21:44:17 +02:00
Willem Wollebrants
fc6f5c138e Update en.php
add a verb to the lengthMin error
2016-07-31 11:57:12 +02:00
Willem Wollebrants
0c9feabe0e Merge pull request #160 from HelgeSverre/master
Added norwegian language file
2016-07-24 11:41:07 +02:00
Helge Sverre
a9169771ef Added norwegian language file 2016-07-24 11:23:39 +02:00
Vance Lucas
86e64c1cd9 Merge pull request #158 from static-m/master
Added Slovak language.
2016-06-29 09:15:02 -05:00
Martin Gazdag [office]
d3660fd6f1 Added Slovak language. 2016-06-29 15:32:56 +02:00
Willem Wollebrants
e55681c9ab Merge pull request #155 from misantron/validators-patch
Contains and between validators
2016-05-22 14:02:59 +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
7ba25fe5af Merge pull request #153 from misantron/develop
English and Russian translations update
2016-03-25 15:48:11 +01:00
misantron
69be152f3a English and russian translations fix 2016-03-24 22:08:52 +03:00
Willem Wollebrants
bb181072f4 added "optional" rule v1.2.5 2016-03-15 22:14:19 +01:00
Willem Wollebrants
9636bfaf19 Merge pull request #151 from laverboy/patch-1
add string '1' as acceptable accepted value
2016-03-15 21:59:55 +01:00
Matthew Laver
0156bfc54e add acceptable accepted value
the string of '1' is also evaluated to true and a post variable is more likely to be set to a string
2016-03-11 10:31:07 +00:00
Willem Wollebrants
39eaf820c1 Change scope of checkAndSetLabel for easier extension 2016-02-22 13:31:29 +01:00
Willem Wollebrants
4112b40452 Merge pull request #140 from MaJerle/master
Added "optional" rule validation: with this rule if a value is provided it will be validated, even if it's an empty string
2016-02-22 13:21:35 +01:00
Tilen Majerle
30b2ce8bc9 Merge pull request #2 from willemwollebrants/master
Add tests for 'optional' rule
2016-02-22 12:19:19 +01:00
Willem Wollebrants
9afa605dc3 Add tests for 'optional' rule 2016-02-22 12:13:02 +01:00
Willem Wollebrants
a5822704b9 Merge pull request #126 from danielfpedro/patch-1
Update pt-br.php
2016-02-20 10:41:13 +01:00
Vance Lucas
2c8e918ced Merge pull request #146 from vanpattenmedia/fields_param_in_rule_callback
Pass fields to callbacks defined in addRule
2016-01-15 13:53:20 -06:00
Vance Lucas
1bef76d58e Merge pull request #120 from Nicat/patch-1
az.php
2016-01-15 13:51:27 -06:00
Vance Lucas
321e8ce69e Merge pull request #147 from tuncayuner/language/turkish
Added Turkish language.
2016-01-15 13:51:11 -06:00
Vance Lucas
7928afcc72 Merge pull request #145 from studiowbe/nl
Dutch translations
2016-01-15 13:50:49 -06:00
tuncayuner
35693dea0a Added Turkish language. 2016-01-11 18:59:46 +02:00
Chris Van Patten
920fefc05a update README to include $fields callback param in code example 2016-01-05 09:57:16 -05:00
Chris Van Patten
3ee508987e Pass $this->_fields to callbacks defined in addRule 2016-01-05 09:48:23 -05:00
Willem Wollebrants
1313fbd632 Add Dutch labels (nl) 2016-01-05 14:56:34 +01:00
Vance Lucas
d2b63c6119 Add 'composer test' as a run script v1.2.4 2015-12-15 14:10:29 -06:00
Vance Lucas
46acc7aa56 Merge pull request #141 from yeesoft/master
Adds Ukrainian language
2015-12-07 18:33:00 -06:00
YeeSoft
94048a95d5 Adds Ukrainian language 2015-12-04 20:31:29 +02:00
Tilen Majerle
708235e0e4 Merge pull request #1 from MaJerle/MaJerle-validate-optional-1
Added "optional" rule validation
2015-11-30 22:23:47 +01:00
Tilen Majerle
0d77529c90 Added "optional" rule validation
With 'optional' rule validation, values does not need to be included in data array.
However, if they are, they must pass validation.

Before this patch, if you pass data with empty ( '' ) value, then it is ignored if "required" was not added.
With this version, this is now fixed.

Text case available here: http://pastebin.com/N2eQjJys
2015-11-30 22:23:21 +01:00
Vance Lucas
a06309ce75 Merge pull request #137 from zonuexe/feature/deny_array
type check
2015-11-24 11:20:47 -06:00