XCL Web Application Platform 2.5.0
The XoopsCube Legacy Project
Loading...
Searching...
No Matches
XCube_Validator.class.php
1<?php
19
29 public function isValid( &$form, $vars ) {
30 }
31}
32
34 public function isValid( &$form, $vars ) {
35 return ! $form->isNull();
36 }
37}
38
40 public function isValid( &$form, $vars ) {
41 if ( $form->isNull() ) {
42 return true;
43 }
44
45 return strlen( $form->toString() ) >= $vars['minlength'];
46 }
47}
48
50 public function isValid( &$form, $vars ) {
51 if ( $form->isNull() ) {
52 return true;
53 }
54
55 return strlen( $form->toString() ) <= $vars['maxlength'];
56 }
57}
58
60 public function isValid( &$form, $vars ) {
61 if ( $form->isNull() ) {
62 return true;
63 }
64
65 return $form->toNumber() >= $vars['min'];
66 }
67}
68
70 public function isValid( &$form, $vars ) {
71 if ( $form->isNull() ) {
72 return true;
73 }
74
75 return $form->toNumber() <= $vars['max'];
76 }
77}
78
80 public function isValid( &$form, $vars ) {
81 if ( $form->isNull() ) {
82 return true;
83 }
84
85 return ( (int) $form->toNumber() >= $vars['min'] && (int) $form->toNumber() <= $vars['max'] );
86 }
87}
88
90 public function isValid( &$form, $vars ) {
91 if ( $form->isNull() ) {
92 return true;
93 }
94
95 return preg_match( "/^[_a-z0-9\-+!#$%&'*\/=?^`{|}~]+(\.[_a-z0-9\-+!#$%&'*\/=?^`{|}~]+)*@[a-z0-9-]+([\.][a-z0-9-]+)+$/i", $form->toString() );
96 }
97}
98
100 public function isValid( &$form, $vars ) {
101 if ( $form->isNull() ) {
102 return true;
103 }
104
105 return preg_match( $vars['mask'], $form->toString() );
106 }
107}
108
110 public function isValid( &$form, $vars ) {
111 if ( $form->isNull() ) {
112 return true;
113 }
114 if ( ! $form instanceof \XCube_FileProperty ) {
115 return true;
116 }
117
118 $extArr = explode( ',', $vars['extension'] );
119 foreach ( $extArr as $ext ) {
120 if ( strtolower( $form->mValue->getExtension() ) == strtolower( $ext ) ) {
121 return true;
122 }
123 }
124
125 return false;
126 }
127}
128
130 public function isValid( &$form, $vars ) {
131 if ( $form->isNull() ) {
132 return true;
133 }
134 if ( ! $form instanceof \XCube_FileProperty ) {
135 return true;
136 }
137
138 return ( $form->mValue->getFileSize() <= $vars['maxfilesize'] );
139 }
140}
Represents the special property which handles uploaded file.