Commit graph

304 commits

Author SHA1 Message Date
Henrique Moody 5ab87d1dd9
Merge branch '1.0' into 1.1 2017-03-14 10:44:11 +01:00
Henrique Moody dc869ac375
Only return "name" as is if it's a string 2017-03-14 10:28:03 +01:00
Henrique Moody b43c9b103b
Better message for Length rule
Update exception message when minimum value and maximum value are the
same.
2017-02-12 18:18:39 +01:00
Henrique Moody e708edd005
Rename rule "Numeric" to "NumericVal" 2016-11-06 18:45:44 +01:00
Henrique Moody 4d72af312f
Update PHP-CS-Fixer settings 2016-10-30 10:39:23 +01:00
Julián Gutiérrez 195a8fe534
Create "Nif" rule
Rule to validate spanish NIF (DNI/NIE/CIF).
2016-10-09 17:50:52 +02:00
Henrique Moody 08ea9b7925
Merge branch '1.1' 2016-09-20 08:45:34 +02:00
Henrique Moody e457f19dbd
Merge branch '1.0' into 1.1 2016-09-20 08:44:39 +02:00
Henrique Moody 98050476c6
Always return a valid exception
If calling the method `getExceptionForPath()` when the exception was
nested but had no child it was returning null. This commit ensures that
it always return a valid exception.
2016-09-19 18:22:39 +02:00
Tomasz Regdos 38aedd01e3
Create "Vatin" rule (VAT identification number)
See https://en.wikipedia.org/wiki/VAT_identification_number
2016-09-19 09:50:50 +02:00
Henrique Moody edf4e49ac6
Merge branch '1.0' into 1.1 2016-09-17 21:30:00 +02:00
Henrique Moody 4bcc4027f8
Try to use the getRelatedByName() method first
Then using the `findMessages()` method, tries to use the method
`getRelatedByName()` before using the `findRelated()` method.

This change was made because since on `KeyNested` rule you may have
names with '.' we'll never get the proper exception using
`findRelated()`.
2016-09-17 21:11:55 +02:00
Henrique Moody 98443bad0c
Get the proper exception when using findMessage() 2016-09-17 21:04:24 +02:00
Henrique Moody 494b67871f
Fix wrong behaviour on AbstractRelated
When you define the name for an `AbstractRelated` instance, you expect
that it also define the name for its child. But, when the child already
had a name the `AbstractRelated` was overwriting its name with the
`reference`.
2016-09-17 20:23:38 +02:00
Henrique Moody 6d0e3a2422
Merge branch '1.0' into 1.1 2016-09-13 11:32:43 +02:00
Henrique Moody 7e88a7a0c8
Always check the type then executing KeyNested 2016-09-12 18:06:10 +02:00
Henrique Moody cc179f9209 Merge branch '1.0' into 1.1 2016-08-03 10:53:00 +02:00
Henrique Moody e5fdd87a16 Rename "Iterable" to "IterableType" 2016-08-03 10:43:33 +02:00
Henrique Moody bb0e40a08e Set template for the only rule in the chain
When there is just one rule in the chain and the there is a defined
template for that, the expected behaviour when using the `check()`
method is to see the exception message with the defined template.
2016-04-08 13:39:57 -03:00
Henrique Moody 46541c7e46 Allow the define brands for credit card validation 2016-04-06 16:42:49 -03:00
Emmerson f40eb63d7b Create "PhpLabel" rule 2016-03-04 21:48:25 -03:00
Henrique Moody b1d0acc2e5 Fix some coding standards with php-cs-fixer 2016-03-04 21:42:27 -03:00
Henrique Moody c2eece6785 Create "IdentityCard" rule
Original-Author: Tomasz Regdos <tomek@regdos.com>.
2016-01-13 22:57:11 -02:00
Tomasz Regdos b8da3a947b Create "Pesel" rule
Create validator for PESEL - Polish Human Identification Number.
2015-12-17 11:25:57 -02:00
Guilherme Siani c828420438 Create "Image" rule 2015-12-14 10:14:26 -02:00
Emmerson eae8ccb72a Fix Age integration tests 2015-11-16 19:20:39 -03:00
William Espindola ecbc5c0a94 Create integration tests for "Age" role 2015-11-09 06:54:51 -02:00
William Espindola f2083a58d7 Create integration tests for "Bsn" rule 2015-11-09 06:54:43 -02:00
Kennedy Tedesco 7d8b18baca Making real tests for Exists rule 2015-11-04 15:52:19 -02:00
Andrew Peters 08a5ab0d81 Use "{less/greater} than or equal to" phrasing 2015-11-04 15:37:43 -02:00
Henrique Moody 59669e6403 Set timezone for tests that work with dates 2015-11-04 14:59:04 -02:00
Emmerson 621b4707b5 Create "LanguageCode" rule 2015-10-26 23:12:21 -03:00
Henrique Moody cd46545855 Small coding standards and docs improvements 2015-10-24 01:32:07 -02:00
Henrique Moody 474afaa2ec Remove "ValidationExceptionInterface" 2015-10-23 09:00:31 -02:00
Henrique Moody 67e072ebd3 Remove "NestedValidationExceptionInterface" 2015-10-23 09:00:18 -02:00
Diego Oliveira 70997912eb Create "Imei" rule 2015-10-23 07:53:59 -02:00
Alexandre Gaigalas 84fa389d4c Implements numeric Key/KeyNested Addressing
The Key and KeyNested rules didn't supported numeric
addressing (e.g. `v::key(42);`). This change implements it and
adds new tests for the behavior.
2015-10-22 10:35:58 -02:00
Henrique Moody 19698d6a38 Move rule integration tests do another directory 2015-10-22 03:22:58 -02:00
Henrique Moody 8c9c587597 Improvements and fixes on exceptions
There were some cases when the exceptions was not displayed property
when using nested exception, this commit fix the problem and also
display messages in Markdown list.
2015-10-22 03:01:41 -02:00
Edson Lima fd6fcd151e Create integration tests for "AllOf" rule 2015-10-21 10:27:22 -02:00
Henrique Moody 03c0bd03de Update message after changing exception properties 2015-10-21 04:14:11 -02:00
Emmerson 29bdb0a9f6 Create "BoolVal" rule 2015-10-21 01:35:05 -03:00
Edson Lima a281ad03d7 Create integration tests for "Consonant" rule 2015-10-21 01:02:19 -02:00
Henrique Moody e2b02b9777 Increase code coverage of rules 2015-10-19 14:17:47 -02:00
Danilo Correa 954c0ca133 Create integration tests for "Equals" rule 2015-10-18 19:11:58 -02:00
Guilherme Siani 1c254ab682 Refactor "ArrayVal" rule and add integration tests 2015-10-18 18:50:07 -02:00
João Torquato f08a1fa9fc Create "ArrayType" rule 2015-10-18 18:01:11 -02:00
Guilherme Siani 767fcaaccf Create "Iterable" rule 2015-10-18 17:27:25 -02:00
Reginaldo Junior 7398588c56 Create "FloatType" rule 2015-10-18 16:57:49 -02:00
Henrique Moody c84020f7f1 Set timezone for tests that work with dates 2015-10-18 16:22:46 -02:00
Justin Hook 4145faab39 Create "CurrencyCode" rule 2015-10-18 14:42:39 -02:00
João Torquato a3694241f2 Create "Countable" rule 2015-10-18 11:37:50 -02:00
Henrique Moody 9c49dd3bcf Use short array syntax 2015-10-17 22:56:32 -03:00
Rafael-BP 6fb15a697c Create integration tests for "ObjectType" rule 2015-10-17 22:25:35 -03:00
Felipe Martins cbbf082c15 Increase tests for "CountryCode" rule
- Add alpha-3 and numeric country codes and unit test for it
- Add new integration tests for CountryCode rule alpha-3 and numeric
2015-10-17 22:21:33 -03:00
Edson Lima 31f1f1c25e Create integration tests for "Beetween" rule 2015-10-17 22:16:01 -03:00
Edson Lima 16ad8f804d Create integration tests for "KeyValue" rule 2015-10-17 22:13:45 -03:00
Danilo Correa 5dc5410617 Crete integration tests for "BoolType" rule 2015-10-17 22:09:54 -03:00
Nawarian 85633cd8b0 Create integration tests for "Length" rule 2015-10-17 21:58:25 -03:00
Antonio Spinelli c6638b9ffb Create integration tests for "When" rule 2015-10-17 21:53:43 -03:00
William Espindola c289b44fe9 Improve integration tests for "Yes" rule 2015-10-17 21:33:40 -03:00
Henrique Moody 59fe72794d Remove integration tests for bank rule 2015-10-17 21:24:47 -03:00
Rogerio Prado de Jesus b1a86e6065 Create integration tests for "Bank" rule
Thanks @gabriercouto and @marcelgsantos for all the words about how to
make it, you guys are amazing :-D.
2015-10-17 18:16:42 -03:00
Gabriel Rodrigues Couto 3c75524cba Create integration tests for "Alpha" rule 2015-10-17 17:46:21 -03:00
Henrique Moody 87604434cf Fix typo on "callableType_4.phpt" test 2015-10-17 17:33:27 -03:00
Rafael-BP 94e552d60c Create integration tests for "CallableType" rule 2015-10-17 17:16:44 -03:00
Gabriel Rodrigues Couto d56905aeba Create Integration tests for "Numeric" rule 2015-10-17 17:10:47 -03:00
Reginaldo Junior 311bd1d762 Create integration tests for "CreditCard" rule 2015-10-17 17:06:18 -03:00
Danilo Correa 68b5cbe94a Create integration tests for "Digit" rule 2015-10-17 17:02:46 -03:00
Emmerson 21c2b4361e Creates integration tests for "Ip" rule 2015-10-17 17:00:11 -03:00
William Espindola 86f4822af3 Create integration test for "Bsn" rule 2015-10-17 16:54:10 -03:00
Marcel dos Santos 1e057c7687 Create integration tests for 'StringType' rule 2015-10-17 16:51:58 -03:00
Guilherme Siani fe17a2a6d8 Increase integration tests of "Alnum" rule
Created integration tests with extra functions of Alnum rule. Also
remove unecessary asserts from the AlnumTest.
2015-10-17 16:31:41 -03:00
Rafael-BP 4e894a7022 Create integration tests of "Optional" rule 2015-10-17 16:10:28 -03:00
Gabriel Rodrigues Couto 503143a90b Create integration tests for "NotEmpty" rule 2015-10-17 15:49:10 -03:00
Gabriel Rodrigues Couto 6ab3467d69 Create integration tests for "NullType" rule 2015-10-17 15:43:20 -03:00
Felipe Martins 08ce0fa455 Increase integration tests for "CountryCode" rule 2015-10-17 15:31:47 -03:00
Marcel dos Santos 669fd48e58 Create integration tests for "Slug" rule 2015-10-17 15:30:07 -03:00
Paulo Eduardo 0526c14cc9 Create integration tests for "Tld" rule 2015-10-17 15:26:09 -03:00
Guilherme Siani 780cedbec3 Created integration tests for "Alnum" rule 2015-10-17 15:22:08 -03:00
Rafael-BP e3a18c6665 Increase tests for "NotOptional" rule 2015-10-17 15:03:03 -03:00
João Torquato cbb0fa74a5 Create integration tests for "MinimumAge" rule 2015-10-17 15:01:21 -03:00
Danilo Correa 2aa368b8c8 Create integration tests from "CNPJ" rule 2015-10-17 14:43:56 -03:00
Gabriel Rodrigues Couto 142486bfcc Create integration tests for "NotBlank" rules 2015-10-17 14:26:58 -03:00
William Espindola ae1dfe6a66 Create integration test for "Yes" rule 2015-10-17 14:24:15 -03:00
Edson Lima 2f0db5ebff Create integration tests for "Email" rule 2015-10-17 14:18:33 -03:00
Henrique Moody ac8fb50400 Create integration tests from "CPF" rule 2015-10-17 12:40:39 -03:00
Henrique Moody 60568eac62 Create "IntType" rule 2015-10-16 23:43:01 -03:00
Henrique Moody d53811f7b7 Remove user-defined optional values
Since we have NotOptional rule now, we must keep the same opposite
behaviour between these two rules.

This commit also improve and increase tests from Optional rule and
updates the documentation.

No tests was made for messages on MODE_DEFAULT because it's not possible
for a while since we don't have such much granularity control, but after
some fixes on Not rule, maybe we will be able to do that, that's why I
kept the messages on OptionalException.
2015-10-15 11:14:20 -03:00
Henrique Moody 15b0a937b2 Create "NotOptional" rule 2015-10-15 10:36:48 -03:00
Henrique Moody 6f9a5771c2 Fix "Not" rule on first level 2015-10-14 13:56:29 -03:00
Henrique Moody 62761ffe18 Make all rules inclusive by default 2015-10-14 13:10:20 -03:00
Ivan Zinovyev 91e9c2053d Create "KeyNested" rule 2015-10-07 14:03:19 -03:00
Henrique Moody 255269bfb3 Rename rule "String" to "StringType" 2015-10-07 11:52:03 -03:00
Henrique Moody 9b85df4601 Rename rule "Int" to "IntVal" 2015-10-07 11:46:57 -03:00
Henrique Moody 937fa6b183 Create documentation for message localization
Also define the `translator` param to the related rules in
`AbstractNestedException`.
2015-10-07 10:18:31 -03:00
Henrique Moody 455ff9b318 Create "Optional" rule 2015-10-07 02:44:33 -03:00
Henrique Moody 62d8909928 Some small coding standard fixes 2015-09-11 02:59:11 -03:00
Henrique Moody 5a41a6bf0c Make exception messages simpler
When the exception has only one related exception, there is no need to
display it's messages unless it has an user-defined template.
2015-09-11 02:49:42 -03:00
Henrique Moody 69f433db6b Create method getMessages() on nested exception 2015-09-10 19:20:31 -03:00
Henrique Moody 748b280c34 Update conversion to strings on exceptions
Many changes were made on `ValidationException::stringify`:
- Add support for instances of `Exception`;
- Add support for instances of `Traversable`;
- Add support for resources;
- Improve `Array` conversion;
- Improve `Object` conversion;
- Improve conversion of all values by using JSON.

Now, all the parameters of the exception classes are just converted to
string when replacing parameters on exceptions, so the exception classes
now keep the original value of all parameters.
2015-09-04 17:11:40 -03:00
Henrique Moody c4e6f0875e Create test for Not rule with recursion 2015-09-04 15:24:03 -03:00
Henrique Moody 743fafb31b Create PHPT tests from AbstractNestedExceptionTest 2015-07-29 17:08:06 -03:00
Henrique Moody 4037209302 Move some tests from ValidatorTest to PHPT files
- setTemplate() with single validator should use template as main
  message
- setTemplate() with multiple validators should use template as main
  message
- setTemplate() with multiple validators should use template as full
  message
- getFullMessage() should include all validation messages in a chain
- not() should work by builder
- countryCode()
- alwaysValid()
- alwaysInvalid()
- Issue #85: findMessages() should not trigger catchable fatal error
- keys as validator names
- Do not rely on nested validation exception interface for check
2015-07-29 01:19:00 -03:00