<?php

/**
 * NotEmpty
 *
 * @author Arkadiusz Rychlik <a.rychlik at eppe.com.pl>
 */
class Eppe_Validate_Gmaps_NotEmpty extends Zend_Validate_NotEmpty {
	
	protected $_requiredFields = [
		'md'=>null, // marker D
		'me'=>null, // marker E
		'cd'=>null, // center D
		'ce'=>null, // center E
		'cz'=>null, // center Zoom
	];
	
	public function isValid($value) {
		$error = false;
		
		if(is_array($value)){
			foreach(array_keys($this->_requiredFields) as $reqKey){
				if ( !(array_key_exists($reqKey, $value) && !empty($value[$reqKey]))) {
					$error = true;
					break;
				}
			}
		}
		else{
			$error = true;
		}
		
		if($error){
			$this->_error(self::IS_EMPTY);
			return false;
		}
		
		return true;
	}
	
}
