Author: xavier
Date: 2010-04-06 15:43:02 +0200 (Tue, 06 Apr 2010)
New Revision: 28995
Modified:
plugins/sfDoctrineRestGeneratorPlugin/trunk/data/generator/sfDoctrineRestGenerator/default/parts/validateCreate.php
plugins/sfDoctrineRestGeneratorPlugin/trunk/data/generator/sfDoctrineRestGenerator/default/parts/validateIndex.php
Log:
[wiki:sfDoctrineRestGeneratorPlugin]: fixed bug in validation of required
parameters in GET request
Modified:
plugins/sfDoctrineRestGeneratorPlugin/trunk/data/generator/sfDoctrineRestGenerator/default/parts/validateCreate.php
===================================================================
---
plugins/sfDoctrineRestGeneratorPlugin/trunk/data/generator/sfDoctrineRestGenerator/default/parts/validateCreate.php
2010-04-06 13:33:53 UTC (rev 28994)
+++
plugins/sfDoctrineRestGeneratorPlugin/trunk/data/generator/sfDoctrineRestGenerator/default/parts/validateCreate.php
2010-04-06 13:43:02 UTC (rev 28995)
@@ -12,7 +12,7 @@
{
if (!isset($validators[$name]))
{
- throw new sfException(sprintf('Could not validate field
"%s"', $name));
+ throw new sfException(sprintf('Could not validate extra
field "%s"', $name));
}
else
{
Modified:
plugins/sfDoctrineRestGeneratorPlugin/trunk/data/generator/sfDoctrineRestGenerator/default/parts/validateIndex.php
===================================================================
---
plugins/sfDoctrineRestGeneratorPlugin/trunk/data/generator/sfDoctrineRestGenerator/default/parts/validateIndex.php
2010-04-06 13:33:53 UTC (rev 28994)
+++
plugins/sfDoctrineRestGeneratorPlugin/trunk/data/generator/sfDoctrineRestGenerator/default/parts/validateIndex.php
2010-04-06 13:43:02 UTC (rev 28995)
@@ -5,16 +5,31 @@
public function validateIndex($params)
{
$validators = $this->getIndexValidators();
+ $unused = array_keys($validators);
foreach ($params as $name => $value)
{
if (!isset($validators[$name]))
{
- throw new sfException(sprintf('Could not validate field
"%s"', $name));
+ throw new sfException(sprintf('Could not validate extra
field "%s"', $name));
}
else
{
$validators[$name]->clean($value);
+ unset($unused[array_search($name, $unused, true)]);
}
}
+
+ // are non given values required?
+ foreach ($unused as $name)
+ {
+ try
+ {
+ $validators[$name]->clean(null);
+ }
+ catch (Exception $e)
+ {
+ throw new sfException(sprintf('Could not validate field
"%s": %s', $name, $e->getMessage()));
+ }
+ }
}
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.