public function validate() { if (empty($this->affiliate_id)) { $this->setError('Commissions must be issued to an affiliate'); } return parent::validate(); }
public function validate() { if (empty($this->initial_value)) { $this->setError('Gift Cards must have an initial value'); } return parent::validate(); }
public function validate() { if (empty($this->amount)) { $this->setError('Credits must have a value'); } if (empty($this->user_id)) { $this->setError('Credits must be issued to a user'); } return parent::validate(); }
public function validate() { if (empty($this->title)) { $this->setError('Title is required'); } // is the path unique? // this would be a great case for $this->validateWith( $validator ); -- using a Uniqueness Validator if ($existing = $this->pathExists($this->path)) { if ((empty($this->_id) || $this->_id != $existing->_id) && $existing->type == $this->type) { $this->setError('An item with this title already exists with this parent.'); } } return parent::validate(); }
public function validate() { if (empty($this->title)) { $this->title = $this->{'url.alias'}; } if (empty($this->{'url.alias'})) { $this->setError('Alias URL is required'); } // is the original URL unique? if ($this->collection()->count(array('url.alias' => $this->{'url.alias'}, '_id' => array('$ne' => $this->id))) > 0) { $this->setError('Redirection for this route already exists.'); } return parent::validate(); }
public function validate() { if (empty($this->name)) { $this->setError('Addresses must have an addressee'); } if (empty($this->line_1)) { $this->setError('Addresses must have the first street line'); } if (empty($this->city)) { $this->setError('Addresses must have a city'); } if (empty($this->region)) { $this->setError('Addresses must have a region/state'); } if (empty($this->country)) { $this->setError('Addresses must have a country'); } if (empty($this->postal_code)) { $this->setError('Addresses must have a postal code'); } return parent::validate(); }
public function validate() { if (!empty($this->invite_id)) { $this->invite_id = new \MongoId((string) $this->invite_id); } if (!empty($this->affiliate_id)) { $this->affiliate_id = new \MongoId((string) $this->affiliate_id); } // ensure required fields if (empty($this->affiliate_id)) { $this->setError('An Affiliate ID is required'); } $affiliate = $this->affiliate(); if (empty($affiliate->id)) { $this->setError('Invalid Affiliate ID'); } if (empty($this->affiliate_email)) { $this->affiliate_email = $affiliate->email; } if (empty($this->referral_user_id)) { $this->setError('The User ID of the referral is required'); } $referral = $this->referral(); if (empty($referral->id)) { $this->setError('Invalid Referral User ID'); } if (empty($this->referral_email)) { $this->referral_email = $referral->email; } if (empty($this->referral_name)) { $this->referral_name = $referral->fullName(); } $referral = static::isUser($this->referral_user_id); if (!empty($referral->id) && $referral->id != $this->id) { $this->setError('Only one referral per user'); } // TODO Validate the referral before creating the commission // 1. Has the user referred themselves? // compare the referral's browser's fingerprint to the affiliate's browser's fingerprint // compare affiliate_id and referral_user_id if ($this->referral_user_id == $this->affiliate_id) { $this->setError('Cannot refer yourself'); } return parent::validate(); }