作者:vigourouxjulie
项目:theli
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = NewsletterQuery::create()->filterByUnsubscribed(false)->findOneByEmail($value);
if ($customer) {
$context->addViolation(Translator::getInstance()->trans("You are already registered!"));
}
}
作者:ibrow
项目:datatran
/**
* @param ExecutionContextInterface $context
*/
public function isValidUppMsgType(ExecutionContextInterface $context)
{
$uppMsgType = $this->getUppMsgType();
if (self::MSGTYPE_GET !== $uppMsgType) {
$context->addViolationAt('status', "Invalid uppMsgType '{$uppMsgType}' given!");
}
}
作者:vigourouxjulie
项目:theli
public function verifyExistingCode($value, ExecutionContextInterface $context)
{
$coupon = CouponQuery::create()->findOneByCode($value);
if (null === $coupon) {
$context->addViolation(Translator::getInstance()->trans("This coupon does not exists"));
}
}
作者:Nairebi
项目:CraueFormFlowBundl
/**
* @Assert\Callback(groups={"flow_revalidatePreviousSteps_step1"})
*/
public function isDataValid(ExecutionContextInterface $context)
{
// valid only on first call
if (++self::$validationCalls > 1) {
$context->addViolation('Take this!');
}
}
作者:vigourouxjulie
项目:theli
public function verifyTaxId($value, ExecutionContextInterface $context)
{
$tax = TaxQuery::create()->findPk($value);
if (null === $tax) {
$context->addViolation("Tax ID not found");
}
}
作者:vigourouxjulie
项目:theli
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::getCustomerByEmail($value);
if ($customer) {
$context->addViolation(Translator::getInstance()->trans("This email already exists."));
}
}
作者:vigourouxjulie
项目:theli
/**
* Validate a date entered with the current edition Language date format.
*
* @param string $value
* @param ExecutionContextInterface $context
*/
public function checkDate($value, ExecutionContextInterface $context)
{
$format = self::PHP_DATE_FORMAT;
if (!empty($value) && false === \DateTime::createFromFormat($format, $value)) {
$context->addViolation(Translator::getInstance()->trans("Date '%date' is invalid, please enter a valid date using %fmt format", ['%fmt' => self::MOMENT_JS_DATE_FORMAT, '%date' => $value]));
}
}
作者:vigourouxjulie
项目:theli
public function checkDuplicateCode($value, ExecutionContextInterface $context)
{
$currency = CurrencyQuery::create()->findOneByCode($value);
if ($currency) {
$context->addViolation(Translator::getInstance()->trans('A currency with code "%name" already exists.', ['%name' => $value]));
}
}
作者:vigourouxjulie
项目:theli
public function verifyEmailField($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if (isset($data["email_confirm"]) && $data["email"] != $data["email_confirm"]) {
$context->addViolation(Translator::getInstance()->trans("email confirmation is not the same as email field"));
}
}
作者:gillesbourgea
项目:cor
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::create()->findOneByEmail($value);
if (null === $customer) {
$context->addViolation(Translator::getInstance()->trans("This email does not exists"));
}
}
作者:vigourouxjulie
项目:theli
public function verifyPasswordField($value, ExecutionContextInterface $context)
{
$data = $context->getRoot()->getData();
if ($data["password"] != $data["password_confirm"]) {
$context->addViolation(Translator::getInstance()->trans("password confirmation is not the same as password field"));
}
}
作者:zyxis
项目:cantig
public function checkPassword(ExecutionContextInterface $context)
{
if (!$this->user->checkPassword($this->encoderFactory, $this->password)) {
$context->buildViolation('The specified password is invalid.')->atPath('password')->addViolation();
return false;
}
}
作者:vigourouxjulie
项目:theli
public function checkRefDifferent($value, ExecutionContextInterface $context)
{
$originalRef = ProductQuery::create()->filterByRef($value, Criteria::EQUAL)->count();
if ($originalRef !== 0) {
$context->addViolation($this->translator->trans('This product reference is already assigned to another product.'));
}
}
作者:vigourouxjulie
项目:theli
public function checkDuplicateName($value, ExecutionContextInterface $context)
{
$config = ConfigQuery::create()->findOneByName($value);
if ($config) {
$context->addViolation(Translator::getInstance()->trans('A variable with name "%name" already exists.', array('%name' => $value)));
}
}
作者:vigourouxjulie
项目:theli
public function checkDuplicateRef($value, ExecutionContextInterface $context)
{
$count = ProductQuery::create()->filterByRef($value)->count();
if ($count > 0) {
$context->addViolation(Translator::getInstance()->trans("A product with reference %ref already exists. Please choose another reference.", array('%ref' => $value)));
}
}
作者:vigourouxjulie
项目:theli
public function verifyCountryList($value, ExecutionContextInterface $context)
{
$jsonType = new JsonType();
if (!$jsonType->isValid($value)) {
$context->addViolation(Translator::getInstance()->trans("Country list is not valid JSON"));
}
$countryList = json_decode($value, true);
foreach ($countryList as $countryItem) {
if (is_array($countryItem)) {
$country = CountryQuery::create()->findPk($countryItem[0]);
if (null === $country) {
$context->addViolation(Translator::getInstance()->trans("Country ID %id not found", ['%id' => $countryItem[0]]));
}
if ($countryItem[1] == "0") {
continue;
}
$state = StateQuery::create()->findPk($countryItem[1]);
if (null === $state) {
$context->addViolation(Translator::getInstance()->trans("State ID %id not found", ['%id' => $countryItem[1]]));
}
} else {
$context->addViolation(Translator::getInstance()->trans("Wrong country definition"));
}
}
}
作者:vigourouxjulie
项目:theli
public function verifyTaxRuleId($value, ExecutionContextInterface $context)
{
$taxRule = TaxRuleQuery::create()->findPk($value);
if (null === $taxRule) {
$context->addViolation(Translator::getInstance()->trans("Tax rule ID not found"));
}
}
作者:vigourouxjulie
项目:theli
public function verifyCountry($value, ExecutionContextInterface $context)
{
$address = CountryQuery::create()->findPk($value);
if (null === $address) {
$context->addViolation(Translator::getInstance()->trans("Country ID not found"));
}
}
作者:zyxis
项目:cantig
public function validateForm($data, ExecutionContextInterface $context)
{
if (empty($data['positionLng']) xor empty($data['positionLat'])) {
$context->buildViolation('BothLattitudeAndLongitudeRequiredText')->atPath(empty($data['positionLng']) ? '[positionLng]' : '[positionLat]')->addViolation();
return false;
}
return true;
}
作者:vigourouxjulie
项目:theli
/**
* @param $value
* @param ExecutionContextInterface $context
*/
public function verifyExistingEmail($value, ExecutionContextInterface $context)
{
$customer = CustomerQuery::getCustomerByEmail($value);
// If there is already a customer for this email address and if the customer is different from the current user, do a violation
if ($customer && $customer->getId() != $this->getRequest()->getSession()->getCustomerUser()->getId()) {
$context->addViolation(Translator::getInstance()->trans("This email already exists."));
}
}