Combines multiple fields to be as one for validation
@return sFire\Validator\Combine
432941
public function combine() {

		$fieldnames = func_get_args();
		$values 	= [];

		foreach($fieldnames as $fieldname) {

			if(false === is_string($fieldname)) {
				return trigger_error(sprintf('All fieldnames used in "%s"() must be of the type string, "%s" given', __METHOD__, gettype($fieldname)), E_USER_ERROR);
			}

			$values[] = $this -> getValue($fieldname, $this -> getPrefix());
		}

		$combine = new Combine();
		$combine -> setValues($values);
		$combine -> setFieldnames($fieldnames);

		$this -> combine[] = $combine;

		return $combine;
	}
1358814
public function addValidation($validation, $value = null)
    {
        if (false === isset($this->validation[$validation])) {
            $this->validation[$validation] = [];
        }

        $this->validation[$validation][] = $value;

        return $this;
    }
519431
protected function make_fields_validation() {
		foreach ( $this->fields as $key => $field ) {
			if ( $this->maybe_skip_field( $field ) ) {
				continue;
			}

			if ( $rules = $field->get_option( 'validate' ) ) {
				$attributes = ( new Rules_Parser( $field ) )->parse( $rules );
				$field->set_attribute( $attributes );
			}
		}
	}
959506
public function validation()
    {
        $validator = new Validation();
        
        $validator->add('email', new Email([
            'message' => 'Invalid email supplied'
        ]));

        $validator->add('email', new Uniqueness(array(
            'message' => 'Sorry, The email has been used by another user'
        )));

        return $this->validate($validator);
    }
408325
public function validate()
    {
        $context = array_merge(['input' => $this], $this->context);
        $values = $this->getValue();
        if (!is_array($values)) {
            $this->valid = $this->getValidationChain()
                ->validates($this->getValue(), $context);
            return $this;
        }
        $this->validateArray($values, $context);
        return $this;
    }
657067
public static function combine($conditions)
    {
        return Arr::join(' AND ', Arr::map(function ($condition) {
            return "(".Condition::render($condition).")";
        }, $conditions));
    }
569296
public function association()
    {
        //====================================================================//
        // Safety Checks ==> Verify a new Field Exists
        if (empty($this->new)) {
            Splash::log()->err("ErrFieldsNoNew");
        } else {
            //====================================================================//
            // Field Clear Fields Associations
            if (!empty($this->new->asso)) {
                $this->new->asso = null;
            }

            //====================================================================//
            // Set New Field Associations
            if (!empty(func_get_args())) {
                $this->new->asso = func_get_args();
            }
        }

        return $this;
    }
696895
private function mergeRules()
    {
        $rules = static::$rules;
        $output = array();

        if (empty ($rules))
        {
            return $output;
        }

        if ($this->exists)
        {
            $merged = (isset($rules['update'])) ? array_merge_recursive($rules['save'], $rules['update']) : $rules['save'];
        } else
        {
            $merged = (isset($rules['create'])) ? array_merge_recursive($rules['save'], $rules['create']) : $rules['save'];
        }

        foreach ($merged as $field => $rules)
        {
            if (is_array($rules))
            {
                $output[$field] = implode("|", $rules);
            } else
            {
                $output[$field] = $rules;
            }
        }

        return $output;
    }
6728
public function validateData()
    {
        $constraint = new Assert\Collection([
            'fields' => $this->getValidationRules(),
        ]);

        $violations = $this->validator->validate($this->getParameters(), $constraint);
        if ($violations->count()) {
            throw new ValidatorException($violations);
        }

        return $this;
    }
143466
def fields_to_validate
      required_fields = to_hash opts[:required]
      optional_fields = to_hash opts[:optional]
      required_fields.keys.each { |key| required_fields[key][:required] = true }
      optional_fields.merge(required_fields)
    end
1238779
private function validateFields() {
    $fieldsRequired = $this->fieldsRequired;
    $returnError = array();

    foreach ($fieldsRequired as $field) {
      if (C2PValidate::isEmpty($this->{$field}) && (!is_numeric($this->{$field})))
        $returnError[] = $field . ' is empty';
    }

    foreach ($this->fieldsSize as $field => $size) {
      if (isset($this->{$field}) && C2PValidate::strlen($this->{$field}) > $size)
        $returnError[] = $field . ' Length ' . $size;
    }

    foreach ($this->fieldsValidate as $field => $method) {
      if (!C2PValidate::isEmpty($this->{$field}) && !call_user_func(array('PayXpert\Connect2Pay\C2PValidate', $method), $this->{$field}))
        $returnError[] = $field . ' = ' . $this->{$field};
    }

    return $returnError;
  }
532943
private function addMultiItem()
    {
        $args = func_get_args();
        $optionKey = array_shift($args);
        $this->items[] = sprintf("%s:%s", $optionKey, implode(',', $args));
        return $this;
    }
587873
protected function formValidation()
    {
        $aRules = [
            'first_name'               => 'max_length[255]',
            'last_name'                => 'max_length[255]',
            'organisation'             => 'max_length[255]',
            'email'                    => 'max_length[255]|valid_email|required',
            'billing_email'            => 'max_length[255]|valid_email',
            'telephone'                => 'max_length[25]',
            'vat_number'               => 'max_length[25]',
            'billing_address_line_1'   => 'max_length[255]',
            'billing_address_line_2'   => 'max_length[255]',
            'billing_address_town'     => 'max_length[255]',
            'billing_address_county'   => 'max_length[255]',
            'billing_address_postcode' => 'max_length[255]',
            'billing_address_country'  => 'max_length[255]',
        ];

        $oFormValidation = Factory::service('FormValidation');
        foreach ($aRules as $sKey => $sRule) {
            $oFormValidation->set_rules($sKey, '', $sRule);
        }

        $oFormValidation->set_message('required', lang('fv_required'));
        $oFormValidation->set_message('max_length', lang('fv_max_length'));
        $oFormValidation->set_message('valid_email', lang('fv_valid_email'));

        if (!$oFormValidation->run()) {
            throw new NailsException(lang('fv_there_were_errors'), 1);
        }

        //  First/Last name is required if no organisation is provided
        $oInput        = Factory::service('Input');
        $sOrganisation = $oInput->post('organisation');
        $sFirstName    = $oInput->post('first_name');
        $sLastName     = $oInput->post('last_name');
        if (empty($sOrganisation) && (empty($sFirstName) || empty($sLastName))) {
            throw new NailsException('First name and surname are required if not providing an organisation.', 1);
        }
    }
589074
public function mergeSubtables()
    {
        $result = $this->getEmptyClone();
        foreach ($this->getDataTables() as $label => $childTable) {
            $result->addTable($childTable->mergeSubtables(), $label);
        }
        return $result;
    }
660878
protected function validateAccountFields()
    {
        $regexpEmail = '/^[^@<>,; "\']+@([^.@ ,;]+\.)+[^.@ ,;]+$/';

        if (empty($this->submittedValues[Tag::ContractCode])) {
            $this->errorMessages[Tag::ContractCode] = $this->t('message_validate_contractcode_0');
        } elseif (!is_numeric($this->submittedValues[Tag::ContractCode])) {
            $this->errorMessages[Tag::ContractCode] = $this->t('message_validate_contractcode_1');
        } else {
            // Prevent errors where a copy & paste of the contractcode from the
            // welcome mail includes spaces or tabs before or after the code.
            $this->submittedValues[Tag::ContractCode] = trim($this->submittedValues[Tag::ContractCode]);
        }

        if (empty($this->submittedValues[Tag::UserName])) {
            $this->errorMessages[Tag::UserName] = $this->t('message_validate_username_0');
        } elseif ($this->submittedValues[Tag::UserName] !== trim($this->submittedValues[Tag::UserName])) {
            $this->warningMessages[Tag::UserName] = $this->t('message_validate_username_1');
        }

        if (empty($this->submittedValues[Tag::Password])) {
            $this->errorMessages[Tag::Password] = $this->t('message_validate_password_0');
        } elseif ($this->submittedValues[Tag::Password] !== trim($this->submittedValues[Tag::Password])) {
            $this->warningMessages[Tag::Password] = $this->t('message_validate_password_1');
        } elseif (strpbrk($this->submittedValues[Tag::Password], '`\'"#%&;<>\\') !== false) {
            $this->warningMessages[Tag::Password] = $this->t('message_validate_password_2');
        }

        if (empty($this->submittedValues[Tag::EmailOnError])) {
            $this->errorMessages[Tag::EmailOnError] = $this->t('message_validate_email_1');
        } elseif (!preg_match($regexpEmail, $this->submittedValues[Tag::EmailOnError])) {
            $this->errorMessages[Tag::EmailOnError] = $this->t('message_validate_email_0');
        }
    }
265760
public function getSelect()
    {
        $concat = null;

        foreach ($this->fieldDescriptors as $fieldDescriptor) {
            if (null == $concat) {
                $concat = $fieldDescriptor->getSelect();
            } else {
                $concat = 'CONCAT(' . $concat . ', CONCAT(\'' . $this->glue . '\', ' . $fieldDescriptor->getSelect() . '))';
            }
        }

        return $concat;
    }
493546
protected function validate()
    {
        // If attributes are set, validate them.
        if (!empty($this->attributes)) {
            // It's possible that there are no rules for the attributes available.
            // If so, skip attribute validation.
            if (sizeof($this->getAttributeRules()) > 0) {
                $validate_attributes = new Validator($this->attributes);
                $validate_attributes->rules($this->getAttributeRules());

                // Validation failed to succeeed, show errors
                if (!$validate_attributes->validate()) {
                    echo 'Some attributes failed to pass the validator:';
                    foreach ($validate_attributes->errors() as $failed_attr) {
                        echo ' '. $failed_attr[0];
                    }
                    return false;
                }
            }
        }

        // If a value is set, validate it.
        if (array_key_exists('value', $this)) {
            // It's possible that there is no value rule set.
            // If so, skip value validation.
            if (sizeof($this->getValueRule()) > 0) {
                $validate_value = new Validator(['value' => $this->value]);
                $validate_value->rules($this->getValueRule());

                // Validation failed to succeeed, show errors
                if (!$validate_value->validate()) {
                    echo "The 'value' failed to pass the validator:";
                    foreach ($validate_value->errors() as $message) {
                        if (is_array($message)) {
                            $message = implode(',', $message);
                        }
                        echo ' '. strtolower($message);
                    }
                    return false;
                }
            }
        }

        return true;
    }