Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Created November 9, 2009 21:55
Show Gist options
  • Select an option

  • Save tobiastom/230304 to your computer and use it in GitHub Desktop.

Select an option

Save tobiastom/230304 to your computer and use it in GitHub Desktop.
<?php
public function validateName($value) {
$collection = new ErrorCollection;
$error = ValidatorA::validate($value);
if($error) {
$collection->addError($error);
}
$error = ValidatorB::validate($value);
if($error) {
$collection->addError($error);
}
$error = ValidatorC::validate($value);
if($error) {
$collection->addError($error);
}
return count($collection) == 0 ? true : $collection;
}
<?php
public function validateName($value, &$error = null) {
$error = null;
ValidatorA::validate($value, $error);
ValidatorB::validate($value, $error);
ValidatorC::validate($value, $error);
return !$error;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment