3
* Pieforms: Advanced web forms made easy
4
* Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
6
* This program is free software: you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation, either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
* @author Nigel McNie <nigel@catalyst.net.nz>
22
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
23
* @copyright (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
28
* Returns whether the given field matches the specified regex.
30
* @param Pieform $form The form the rule is being applied to
31
* @param string $value The value to check
32
* @param array $element The element to check
33
* @param string $regex The regular expression to use for the check
34
* @return string The error message, if there is something wrong with
37
function pieform_rule_regex(Pieform $form, $value, $element, $regex) {/*{{{*/
38
if (!preg_match($regex, $value)) {
39
return $form->i18n('rule', 'regex', 'regex', $element);
43
function pieform_rule_regex_i18n() {/*{{{*/
46
'regex' => 'This field is not in valid form'
49
'regex' => 'Das Feld hat keine zulässige Form'
52
'regex' => 'Ce champ n\'a pas une forme correcte'