english/libraries/joomla/form/form.php
/**
	 * Method to validate form data.
	 *
	 * Validation warnings will be pushed into JForm::errors and should be
	 * retrieved with JForm::getErrors() when validate returns boolean false.
	 *
	 * @param   array   $data   An array of field values to validate.
	 * @param   string  $group  The optional dot-separated form group path on which to filter the
	 *                          fields to be validated.
	 *
	 * @return  mixed  True on sucess.
	 *
	 * @since   11.1
	 */
Method to validate form data.
Validation warnings will be pushed into JForm::errors and should be
retrieved with JForm::getErrors() when validate returns boolean false.

@param   array   $data   An array of field values to validate.
@param   string  $group  The optional dot-separated form group path on which to filter the
fields to be validated.

@return  mixed  True on sucess.


Method to validate form data . Validation warnings will be pushed into JForm :: errors and should be retrieved with JForm :: getErrors () when validate returns boolean false . @param array $data An array of field values to validate . @param string $group The optional dot - separated form group path on which to filter the fields to be validated . @return mixed True on sucess .
public function validate($data, $group = null)
	{
		if (!($this->xml instanceof JXMLElement)) {
			return false;
		}
		$return	= true;
		$input = new JRegistry($data);
		$fields = $this->findFieldsByGroup($group);
		if (!$fields) {
			return false;
		}
		foreach ($fields as $field)
		{
			$value	= null;
			$name	= (string) $field['name'];
			$attrs	= $field->xpath('ancestor::fields[@name]/@name');
			$groups	= array_map('strval', $attrs ? $attrs : array());
			$group	= implode('.', $groups);
			if ($group) {
				$value = $input->get($group.'.'.$name);
			}
			else {
				$value = $input->get($name);
			}
			$valid = $this->validateField($field, $group, $value, $input);
			if (JError::isError($valid)) {
				switch ($valid->get('level'))
				{
					case E_ERROR:
						JError::raiseWarning(0, $valid->getMessage());
						return false;
						break;
					default:
						array_push($this->errors, $valid);
						$return = false;
						break;
				}
			}
		}
		return $return;
	}
public function validate ( $ data , $ group = null ) { if ( ! ( $ this -> xml instanceof JXMLElement ) ) { return false ; } $ return = true ; $ input = new JRegistry ( $ data ) ; $ fields = $ this -> findFieldsByGroup ( $ group ) ; if ( ! $ fields ) { return false ; } foreach ( $ fields as $ field ) { $ value = null ; $ name = ( string ) $ field [ 'name' ] ; $ attrs = $ field -> xpath ( 'ancestor::fields[@name]/@name' ) ; $ groups = array_map ( 'strval' , $ attrs ? $ attrs : array ( ) ) ; $ group = implode ( '.' , $ groups ) ; if ( $ group ) { $ value = $ input -> get ( $ group . '.' . $ name ) ; } else { $ value = $ input -> get ( $ name ) ; } $ valid = $ this -> validateField ( $ field , $ group , $ value , $ input ) ; if ( JError :: isError ( $ valid ) ) { switch ( $ valid -> get ( 'level' ) ) { case E_ERROR : JError :: raiseWarning ( 0 , $ valid -> getMessage ( ) ) ; return false ; break ; default : array_push ( $ this -> errors , $ valid ) ; $ return = false ; break ; } } } return $ return ; }
Method to validate form data.
Method to validate form data .
// Make sure there is a valid JForm XML document. // Initialise variables. // Create an input registry object from the data to validate. // Get the fields for which to validate the data. // PANIC! // Validate the fields. // Initialise variables. // Get the group names as strings for ancestor fields elements. // Get the value from the input data. // Validate the field. // Check for an error.