本文整理汇总了PHP中Symfony\Component\Validator\ExecutionContext::addViolationAtSubPath方法的典型用法代码示例。如果您正苦于以下问题:PHP ExecutionContext::addViolationAtSubPath方法的具体用法?PHP ExecutionContext::addViolationAtSubPath怎么用?PHP ExecutionContext::addViolationAtSubPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Validator\ExecutionContext
的用法示例。
在下文中一共展示了ExecutionContext::addViolationAtSubPath方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isValid
public function isValid(ExecutionContext $context)
{
$is_valid = $this->start <= $this->end;
if (!$is_valid) {
$context->addViolationAtSubPath('end', 'cjsissingh_calendar.validation.event_dates', array(), null);
}
}
示例2: isMortgageSettingsValid
public function isMortgageSettingsValid(ExecutionContext $context)
{
// field requirements for sites without parents
$parentSite = $this->site->getParentSite();
if (!isset($parentSite)) {
$requiredFields = array('loan_document_vocab');
foreach ($requiredFields as $field) {
if (empty($this->{$field})) {
$context->addViolationAtSubPath($field, 'This value is required.', array(), null);
}
}
}
}
示例3: isLoanOfficerValid
/**
* @param ExecutionContext $context
*/
public function isLoanOfficerValid(ExecutionContext $context)
{
$losConn = $this->site->getSettings()->getInheritedLos();
if (isset($losConn)) {
// make sure they enter an los id
if (empty($this->los_id)) {
$context->addViolationAtSubPath('los_id', 'This field is required.', array(), null);
}
}
}
示例4: esDniValido
public function esDniValido(ExecutionContext $context)
{
$dni = $this->getDni();
// Comprobar que el formato sea correcto
if (0 === preg_match("/\\d{1,8}[a-z]/i", $dni)) {
$msg = 'El DNI introducido no tiene el formato correcto (entre 1 y ' . '8 números seguidos de una letra, sin guiones y sin dejar ' . 'ningún espacio en blanco)';
$context->addViolationAtSubPath('dni', $msg, array(), null);
return;
}
// Comprobar que la letra cumple con el algoritmo
$numero = substr($dni, 0, -1);
$letra = strtoupper(substr($dni, -1));
if ($letra != substr("TRWAGMYFPDXBNJZSQVHLCKE", strtr($numero, "XYZ", "012") % 23, 1)) {
$msg = 'La letra no coincide con el número del DNI. Comprueba que ' . 'has escrito bien tanto el número como la letra';
$context->addViolationAtSubPath('dni', $msg, array(), null);
return;
}
}
示例5: isPackageUnique
public function isPackageUnique(ExecutionContext $context)
{
try {
if ($this->entityRepository->findOneByName($this->name)) {
$context->addViolationAtSubPath('repository', 'A package with the name ' . $this->name . ' already exists.', array(), null);
}
} catch (\Doctrine\ORM\NoResultException $e) {
}
}
示例6: isPasswordLegal
/**
* Validate password
*
* @param ExecutionContext $context
*/
public function isPasswordLegal(ExecutionContext $context)
{
$password = $this->getPlainPassword();
if ($password == $this->getUsername()) {
$context->addViolationAtSubPath('plainPassword', 'Email and password cant be the same', array(), null);
}
if (strlen($password) > 0) {
if (!(strlen($password) >= 6 && preg_match('`[A-Z]{1,}`', $password) && preg_match('`[0-9]{1,}`', $password))) {
$context->addViolationAtSubPath('plainPassword', 'Password is not valid!', array(), null);
}
if (strlen(stristr($password, $this->getFirstName())) > 0) {
$context->addViolationAtSubPath('plainPassword', 'Password cannot contain your name', array(), null);
}
if (strlen(stristr($password, $this->getLastName())) > 0) {
$context->addViolationAtSubPath('plainPassword', 'Password cannot contain your name', array(), null);
}
}
}