This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/tests/Symfony/Tests/Component
Fabien Potencier e056480ab2 merged branch bschussek/collection-validator (PR #3118)
Commits
-------

e6e3da5 [Validator] Improved test coverage of CollectionValidator and reduced test code duplication
509c7bf [Validator] Moved Optional and Required constraints to dedicated sub namespace.
bf59018 [Validator] Removed @api-tag from Optional and Required constraint, since these two are new.
6641f3e [Validator] Added constraints Optional and Required for the CollectionValidator

Discussion
----------

[Validator] Improve support for optional/required fields in Collection constraint

Bug fix: no
Feature addition: yes
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: none
Todo: none

![Travis Build Status](https://secure.travis-ci.org/bschussek/symfony.png?branch=collection-validator)

Improves the `Collection` constraint to test on a more granular level if entries of the collection are optional or required. Before this could only be set using the "allowExtraFields" and "allowMissingFields" options, but these are very general and limited.

The former syntax - without Optional or Required - is still supported.

Usage:

    $array = array(
        'name' => 'Bernhard',
        'birthdate' => '1970-01-01',
    );
    $validator->validate($array, null, new Collection(array(
        'name' => new Required(),
        'birthdate' => new Optional(),
    ));

    // you can also pass additional constraints for the fields
    $validator->validate($array, null, new Collection(array(
        'name' => new Required(array(
            new Type('string'),
            new MinLength(3),
        )),
        'birthdate' => new Optional(new Date()),
    ));

---------------------------------------------------------------------------

by canni at 2012-01-15T20:22:17Z

@bschussek I've rewritten a lot of test code for Collection validator in 2.0 branch and also had modified validator itself, as it had a bug #3078, consider waiting with this PR till fabpot will merge 2.0 back into master, as there will be code conflicts :)

---------------------------------------------------------------------------

by Koc at 2012-01-15T23:13:04Z

Does it helps to #2615 ?

---------------------------------------------------------------------------

by fabpot at 2012-01-16T06:44:53Z

@canni: I've just merged 2.0 into master.

---------------------------------------------------------------------------

by bschussek at 2012-01-16T12:05:19Z

@fabpot: Rebased. I also fixed the CS issues mentioned by @stof.
2012-01-16 21:56:42 +01:00
..
BrowserKit [BrowserKit] first attempt at fixing CookieJar (closes #2209) 2011-12-31 16:32:51 +01:00
ClassLoader merged 2.0 2011-09-28 16:08:31 +02:00
Config [Tests] Use proper assertion for counting 2011-12-19 10:00:41 +01:00
Console [Console] Fix tests on windows 2012-01-09 17:05:16 +01:00
CssSelector [DoctrineBridge] fixed some CS 2011-12-13 10:22:12 +01:00
DependencyInjection merged 2.0 2012-01-09 11:51:30 +01:00
DomCrawler merged 2.0 2011-12-13 16:12:53 +01:00
EventDispatcher [EventDispatcher] Added missing object destruction in test tearDown() and removed duplicated tests. 2011-12-05 14:32:28 +05:45
Finder [Finder] added a convenience method Finder::create() 2011-06-14 14:18:24 +02:00
Form [Form] Made validation of form children configurable. Set the option "cascade_validation" to true if you need it. 2012-01-16 20:49:43 +01:00
HttpFoundation merged 2.0 2012-01-09 11:51:30 +01:00
HttpKernel [HttpKernel] Minor fixes in the Stopwatch 2012-01-10 22:23:16 +01:00
Locale [Locale] StubNumberFormatter allow to parse 64bit number in 64bit mode 2011-12-11 17:45:39 +01:00
Process merged 2.0 2011-12-20 20:16:39 +01:00
Routing [Routing] removed trailing slash support for routes that are not available for GET/HEAD methods (as the redirection will always occurs with a GET/HEAD request, closes #2626) 2011-12-30 19:30:23 +01:00
Security Add some more tests, and enforce boolean return value of interface implementations. 2012-01-10 21:55:05 +01:00
Serializer Updated GetSetMethodNormalizerTest to expect camelCased functions instead of lowercased 2012-01-08 13:55:41 -08:00
Templating [Templating] fixed 'scheme://' not detected as absolute path 2011-12-08 15:42:21 +01:00
Translation [Translation] Po/MoFileLoader parse plurization rules 2012-01-03 18:44:44 +01:00
Validator [Validator] Improved test coverage of CollectionValidator and reduced test code duplication 2012-01-16 13:03:38 +01:00
Yaml merged 2.0 2011-12-18 14:48:17 +01:00