MIOLO20
Carregando...
Procurando...
Nenhuma entrada encontrada
mvalidator.class
Ir para a documentação deste ficheiro.
1<?php
7{
8
12 var $field;
13
17 var $min;
18
22 var $max;
23
27 var $type = 'required'; // ex. required | optional | ignore/ readonly
28
32 var $chars;
33
37 var $mask;
38
43
48
49
57 function __construct()
58 {
59 parent::__construct('');
60 $this->page->AddScript('m_validate.js');
61 }
62
70 function Generate()
71 {
73 $name = str_replace('.', '_', $name);
74
75 // Unique identifier. Remove [] to avoid javascript errors.
76 $identifier = str_replace(']', '', str_replace('[', '_', $this->field));
77 $identifier = str_replace('.', '_', $identifier);
78
79 $html =
80<<< HERE
81
82var $name = new MIOLO_Validator();
83$name.id = '{$this->id}';
84$name.form = '{$this->form}';
85$name.field = '{$this->field}';
86$name.label = '{$this->label}';
87$name.min = '{$this->min}';
88$name.max = '{$this->max}';
89$name.type = '{$this->type}';
90$name.chars = '{$this->chars}';
91$name.mask = '{$this->mask}';
92$name.msgerr= '{$this->msgerr}';
93
94if ( !window.MIOLO_validators )
95{
96 window.MIOLO_validators = {};
97}
98window.MIOLO_validators.$identifier = $name;
99
100HERE;
101 if ( $this->checker )
102 {
103 $html .= "$name.checker = 'MIOLO_Validate_Check_{$this->checker}';";
104 }
105 return $html;
106 }
107}
108
114{
128 {
129 parent::__construct();
130 $this->id = 'required';
131 $this->field = $field;
132 $this->label = $label;
133 $this->mask = '';
134 $this->type = 'required';
135 $this->min = 0;
136 $this->max = $max;
137 $this->chars = 'ALL';
138 $this->msgerr = $msgerr;
139 }
140}
141
147{
163 function __construct($field,$label='',$mask,$type = 'ignore',$msgerr='')
164 {
165 parent::__construct();
166 $this->id = 'mask';
167 $this->field = $field;
168 $this->label = $label;
169 $this->mask = $mask;
170 $this->type = $type;
171 $this->min = 0;
172 $this->max = strlen($mask);
173 $this->msgerr = $msgerr;
174 $this->chars = 'ALL';
175 }
176}
177
182{
183
192 public function __construct($field, $label='', $type='optional', $msgerr='')
193 {
194 parent::__construct();
195
196 $this->id = 'email';
197 $this->field = $field;
198 $this->label = $label;
199 $this->type = $type;
200 $this->min = 0;
201 $this->max = 99;
202 $this->chars = 'ALL';
203 $this->mask = '';
204 $this->checker = 'EMAIL';
205 $this->msgerr = $msgerr;
206 }
207}
208
214{
229 function __construct($field,$label='',$type = 'required',$msgerr='')
230 {
231 parent::__construct();
232 $this->id = 'password';
233 $this->field = $field;
234 $this->label = $label;
235 $this->type = $type;
236 $this->min = 0;
237 $this->max = 99;
238 $this->chars = 'ALL';
239 $this->mask = '';
240 $this->checker = 'PASSWORD';
241 $this->msgerr = $msgerr;
242 }
243}
244
250{
265 function __construct($field,$label='',$type = 'optional',$msgerr='')
266 {
267 parent::__construct();
268 $this->id = 'cep';
269 $this->field = $field;
270 $this->label = $label;
271 $this->type = $type;
272 $this->min = 9;
273 $this->max = 9;
274 $this->chars = '0123456789-';
275 $this->mask = '99999-999';
276 $this->msgerr = $msgerr;
277 }
278}
279
285{
300 function __construct($field,$label='',$type = 'optional',$msgerr='')
301 {
302 parent::__construct();
303 $this->id = 'phone';
304 $this->field = $field;
305 $this->label = $label;
306 $this->type = $type;
307 $this->chars = '() 01234-56789';
308 $this->mask = '(99) 99999-9999';
309 $this->msgerr = $msgerr;
310 }
311}
312
318{
333 function __construct($field,$label='',$type = 'optional',$msgerr='')
334 {
335 parent::__construct();
336 $this->id = 'time';
337 $this->field = $field;
338 $this->label = $label;
339 $this->type = $type;
340 $this->min = 5;
341 $this->max = 5;
342 $this->chars = ':0123456789';
343 $this->mask = '99:99';
344 $this->checker = 'TIME';
345 $this->msgerr = $msgerr;
346 }
347}
348
354{
369 function __construct($field,$label='',$type = 'optional',$msgerr='')
370 {
371 parent::__construct();
372 $this->id = 'cpf';
373 $this->field = $field;
374 $this->label = $label;
375 $this->type = $type;
376 $this->min = 14;
377 $this->max = 14;
378 $this->chars = '.-0123456789';
379 $this->mask = '999.999.999-99';
380 $this->checker = 'CPF';
381 $this->msgerr = $msgerr;
382 }
383}
384
390{
405 function __construct($field,$label='',$type = 'optional',$msgerr='')
406 {
407 parent::__construct();
408 $this->id = 'cnpj';
409 $this->field = $field;
410 $this->label = $label;
411 $this->type = $type;
412 $this->min = 18;
413 $this->max = 18;
414 $this->chars = '/.-0123456789';
415 $this->mask = '99.999.999/9999-99';
416 $this->checker = 'CNPJ';
417 $this->msgerr = $msgerr;
418 }
419}
420
426{
441 function __construct($field,$label='',$type = 'optional',$msgerr='')
442 {
443 parent::__construct();
444 $this->id = 'datedmy';
445 $this->field = $field;
446 $this->label = $label;
447 $this->type = $type;
448 $this->min = 10;
449 $this->max = 10;
450 $this->chars = '/0123456789';
451 $this->mask = '99/99/9999';
452 $this->checker = 'DATEDMY';
453 $this->msgerr = $msgerr;
454 }
455}
456
462{
477 function __construct($field,$label='',$type = 'optional',$msgerr='')
478 {
479 parent::__construct();
480 $this->id = 'dateymd';
481 $this->field = $field;
482 $this->label = $label;
483 $this->type = $type;
484 $this->min = 10;
485 $this->max = 10;
486 $this->chars = '/0123456789';
487 $this->mask = '9999/99/99';
488 $this->checker = 'DATEYMD';
489 $this->msgerr = $msgerr;
490 }
491}
492
498{
503
508
512 var $datatype; // 'i' (integer) ou 's' (string)
513
514
532 function __construct($field,$label='', $operator, $value, $datatype='s', $type = 'optional',$msgerr='')
533 {
534 parent::__construct();
535 $this->id = 'compare';
536 $this->field = $field;
537 $this->label = $label;
538 $this->type = $type;
539 $this->min = 0;
540 $this->max = 255;
541 $this->chars = 'ALL';
542 $this->mask = '';
543 $this->checker = 'COMPARE';
544 $this->operator = $operator;
545 $this->value = $value;
546 $this->datatype = strtolower($datatype);
547 $this->msgerr = $msgerr;
548 }
549
557 function Generate()
558 {
560 $html = parent::Generate();
561 $html .= "$name.operator = '{$this->operator}';\n";
562 $html .= "$name.value = '{$this->value}';\n";
563 $html .= "$name.datatype = '{$this->datatype}';\n";
564 return $html;
565 }
566}
567
573{
578
583
587 var $datatype; // 'i' (integer) ou 's' (string) ou 'd' (date)
588
589
607 function __construct($field,$label='', $min, $max, $datatype='s', $type = 'optional',$msgerr='', $separator='.')
608 {
609 parent::__construct();
610 $this->id = 'range';
611 $this->field = $field;
612 $this->label = $label;
613 $this->type = $type;
614 $this->min = 0;
615 $this->max = 255;
616 $this->mask = '';
617 $this->checker = 'RANGE';
618 $this->minvalue = $min;
619 $this->maxvalue = $max;
620 $this->datatype = strtolower($datatype); // 'i' (integer) ou 's' (string)
621 $this->chars = $this->datatype == 'i' || $this->datatype == 'f' ? '+-0123456789' : 'ALL';
622
623 if ( $this->datatype == 'f' )
624 {
625 $this->chars .= $separator;
626 }
627
628 $this->msgerr = $msgerr;
629 }
630
638 function Generate()
639 {
641 $html = parent::Generate();
642 $html .= "$name.minvalue = '{$this->minvalue}';\n";
643 $html .= "$name.maxvalue = '{$this->maxvalue}';\n";
644 $html .= "$name.datatype = '{$this->datatype}';\n";
645 return $html;
646 }
647}
648
654{
659
660
676 function __construct($field,$label='', $regexp='', $type = 'optional',$msgerr='')
677 {
678 parent::__construct();
679 $this->id = 'regexp';
680 $this->field = $field;
681 $this->label = $label;
682 $this->type = $type;
683 $this->min = 0;
684 $this->max = 255;
685 $this->chars = 'ALL';
686 $this->mask = '';
687 $this->checker = 'REGEXP';
688 $this->regexp = $regexp;
689 $this->msgerr = $msgerr;
690 }
691
699 function Generate()
700 {
701 $name = str_replace(".", "_", $this->name);
702 $html = parent::Generate();
703 $html .= "$name.regexp = '{$this->regexp}';\n";
704 return $html;
705 }
706}
707
713{
728 function __construct($field,$label='', $type = 'optional',$msgerr='')
729 {
730 parent::__construct($field,$label, '^[+-]?[0-9][0-9]*$', $type,$msgerr);
731 }
732}
733
739{
754 function __construct($field, $label='', $separator='.', $precision=2, $type = 'optional',$msgerr='')
755 {
756 parent::__construct($field, $label, '^[+-]?[0-9]{1,}(\\'.$separator.'[0-9]{1,'.$precision.'})?$', $type,$msgerr);
757 $this->chars = '0123456789+-'.$separator;
758 }
759}
760
761
767{
782 function __construct($field,$label='',$type = 'optional',$msgerr='')
783 {
784 parent::__construct();
785 $this->id = 'datetimedmy';
786 $this->field = $field;
787 $this->label = $label;
788 $this->type = $type;
789 $this->min = 10;
790 $this->max = 16;
791 $this->chars = ':/0123456789 ';
792 $this->mask = '99/99/9999 99:99';
793 $this->checker = 'DATETimeDMY';
794 $this->msgerr = $msgerr;
795 }
796
797}
798
799
800?>
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $operator, $value, $datatype='s', $type='optional', $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $separator='.', $precision=2, $type='optional', $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $mask, $type='ignore', $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')
__construct($field, $label='', $type='required', $msgerr='')
__construct($field, $label='', $min, $max, $datatype='s', $type='optional', $msgerr='', $separator='.')
__construct($field, $label='', $regexp='', $type='optional', $msgerr='')
__construct($field, $label='', $max=0, $msgerr='')
__construct($field, $label='', $type='optional', $msgerr='')