<?php

/**
 * Goweb Sitemanager 5 Framework
 * 
 * @version    5.0.0
 * @category   Goweb
 * @package    Goweb_Validate
 * @author     I&D <dev@goweb.pt>, Pedro Pinto <ppinto@goweb.pt>
 * @copyright  2009 (c) Goweb (http://www.goweb.pt)
 */

/**
 * Goweb_Validate
 */
Goweb::loadClass('Zend_Validate_File_Size');

/**
 * Classe para validar campos obrigaterios
 *
 * @version    5.0.0
 * @category   Goweb
 * @package    Goweb_Validate
 * @author     I&D <dev@goweb.pt>, Pedro Pinto <ppinto@goweb.pt>
 * @copyright  2009 (c) Goweb (http://www.goweb.pt)
 */
class Goweb_Validate_FileSize extends Zend_Validate_File_Size{
    /**
     * Constructor
     *
     * @param  string  $errorMessage
     * @param  array   $params        Paremetro "max_size"
     */    
    public function __construct($errorMessage, $params) {
        if (!isset($params['max_size'])){
            throw new Goweb_Exception("Para o validador 'Goweb_Validate_FileSize' e obrigatório o parâmetro 'max_size'.");
        }
        $params['max'] = $params['max_size'];
        unset($params['max_size']);
        parent::__construct($params);
        foreach (array_keys($this->_messageTemplates) as $key) $this->setMessage($errorMessage, $key);
    }    
}