src/Articus/DataTransfer/Validator.php
public function validate(array $array)
	{
		$messages = [];
		foreach ($this->metadata->fields as $field)
		{
			$value = array_key_exists($field, $array)? $array[$field] : null;
			if (!(($value === null) && $this->metadata->nullables[$field]))
			{
				$validator = $this->getValidator($field);
				if (!$validator->isValid($value))
				{
					$messages[$field] = $validator->getMessages();
				}
			}
		}
		$globalValidator = $this->getValidator(self::GLOBAL_VALIDATOR_KEY);
		if (!$globalValidator->isValid($array))
		{
			$messages[self::GLOBAL_VALIDATOR_KEY] = $globalValidator->getMessages();
		}
		return $messages;
	}
public function validate(array $array)
	{
		$messages = [];
		foreach ($this->metadata->fields as $field)
		{
			$value = array_key_exists($field, $array)? $array[$field] : null;
			if (!(($value === null) && $this->metadata->nullables[$field]))
			{
				$validator = $this->getValidator($field);
				if (!$validator->isValid($value))
				{
					$messages[$field] = $validator->getMessages();
				}
			}
		}
		$globalValidator = $this->getValidator(self::GLOBAL_VALIDATOR_KEY);
		if (!$globalValidator->isValid($array))
		{
			$messages[self::GLOBAL_VALIDATOR_KEY] = $globalValidator->getMessages();
		}
		return $messages;
	}
public function validate ( array $ array ) { $ messages = [ ] ; foreach ( $ this -> metadata -> fields as $ field ) { $ value = array_key_exists ( $ field , $ array ) ? $ array [ $ field ] : null ; if ( ! ( ( $ value === null ) && $ this -> metadata -> nullables [ $ field ] ) ) { $ validator = $ this -> getValidator ( $ field ) ; if ( ! $ validator -> isValid ( $ value ) ) { $ messages [ $ field ] = $ validator -> getMessages ( ) ; } } } $ globalValidator = $ this -> getValidator ( self :: GLOBAL_VALIDATOR_KEY ) ; if ( ! $ globalValidator -> isValid ( $ array ) ) { $ messages [ self :: GLOBAL_VALIDATOR_KEY ] = $ globalValidator -> getMessages ( ) ; } return $ messages ; }
Validates associative array according metadata
@param array $array
@return array
Validates associative array according metadata