Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

69 lines (57 sloc) 1.612 kb
<?php
/**
* This file is part of the PropelBundle package.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* @license MIT License
*/
namespace Propel\PropelBundle\Validator\Constraint;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
/**
* Constraint for the Unique Object validator
*
* @author Maxime AILLOUD <maxime.ailloud@gmail.com>
* @author Marek Kalnik <marekk@theodo.fr>
*/
class UniqueObject extends Constraint
{
/**
* @var string
*/
public $message = 'A {{ object_class }} object already exists with {{ fields }}';
/**
* @var string Used to merge multiple fields in the message
*/
public $messageFieldSeparator = ' and ';
/**
* @var array
*/
public $fields = array();
public function __construct($options = null)
{
parent::__construct($options);
if (!is_array($this->fields) && !is_string($this->fields)) {
throw new UnexpectedTypeException($this->fields, 'array');
}
if (0 === count($this->fields)) {
throw new ConstraintDefinitionException("At least one field must be specified.");
}
}
/**
* {@inheritDoc}
*/
public function getRequiredOptions()
{
return array('fields');
}
/**
* {@inheritDoc}
*/
public function getTargets()
{
return self::CLASS_CONSTRAINT;
}
}
Jump to Line
Something went wrong with that request. Please try again.