<?
class frmValidators extends MForm
{
    public function __construct()
    {   
		parent::__construct('Validators Sample');
	}

	function CreateFields()
	{
	   $fields = array(
           new MTextField('tfRequired','value','Required',20),
           new MTextField('tfMask','12ab34cd','Mask',20,'mask: 99aa99aa'),
           new MTextField('tfEmail','a@miolo.ufjf.br','Email',50),
           new MTextField('tfCep','36100-000','CEP',15),
           new MTextField('tfPhone','333-3333','Phone',15),
           new MTextField('tfTime','12:12','Time',15),
           new MTextField('tfCPF','','CPF',20),
           new MTextField('tfCNPJ','','CNPJ',20),
           new MTextField('tfDateDMY','12/07/2003','Date DMY',20),
           new MTextField('tfDateYMD','2003/07/31','Date YMD',20),
           new MTextField('tfCompare','5','Compare',5,' >= 10'),
           new MTextField('tfRange1','5','Range Int',5,'[3..10]'),
           new MTextField('tfRange2','cor','Range Str',20,'[a..f]'),
           new MTextField('tfRange3','12/07/2003','Range Date',20,'[10/03/2003..05/10/2003]'),
// validator inline
           new MTextField('tfRegExp','teste@email.com','Reg. Exp.',20,
               'email: [A-Za-z0-9_]+\@[A-Za-z0-9_]+\.[A-Za-z0-9_]+'),
           new MTextField('tfInteger','','Integer',20, 'regexp: (^-?[0-9][0-9]*$)'),
           new MTextField('tfInteger1','0','Integer1',20),
           new MTextField('tfRequired1','ab123','Req. Inline',20,'inserido na criação do campo - maskValidator',
                          new MMaskValidator('tfRequired1','','aa999','required')
                        )
       );
       $this->setFields($fields);
       $validators = array(
           new MRequiredValidator('tfRequired'),
           new MMaskValidator('tfMask','','99aa99aa','required'),
           new MEmailValidator('tfEmail','','required'),
           new MCepValidator('tfCep','','required'),
           new MPhoneValidator('tfPhone','','required'),
           new MTimeValidator('tfTime','','required'),
           new MCPFValidator('tfCPF','','optional'),
           new MCNPJValidator('tfCNPJ','','optional'),
           new MDateDMYValidator('tfDateDMY','','required'),
           new MDateYMDValidator('tfDateYMD','','required'),
           new MCompareValidator('tfCompare','','>=','10','i','required'),
           new MRangeValidator('tfRange1','','3','10','i','required'),
           new MRangeValidator('tfRange2','','a','f','s','required'),
           new MRangeValidator('tfRange3','',
                              '10/03/2003','05/10/2003','d','required'),
           new MRegExpValidator('tfRegExp','', 
                               '[A-Za-z0-9_]+\@[A-Za-z0-9_]+\.[A-Za-z0-9_]+'),
           new MRegExpValidator('tfInteger','','(^-?[0-9][0-9]*$)'),
           new MIntegerValidator('tfInteger1','','required')
       );
       $this->setValidators($validators);
	}
}

?>
