minlength.php 2.43 KB
Newer Older
1
2
<?php
/**
3
4
 * Pieforms: Advanced web forms made easy
 * Copyright (C) 2006-2008 Catalyst IT Ltd (http://www.catalyst.net.nz)
5
 *
6
7
8
9
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
10
 *
11
12
13
14
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
15
 *
16
17
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 *
19
20
 * @package    pieform
 * @subpackage rule
21
22
 * @author     Nigel McNie <nigel@catalyst.net.nz>
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
23
 * @copyright  (C) 2006-2008 Catalyst IT Ltd http://catalyst.net.nz
24
25
26
 *
 */

27
28
29
/**
 * Checks whether the given value is shorter than the allowed length.
 *
30
31
32
33
34
 * @param PieForm $form      The form the rule is being applied to
 * @param string  $value     The value to check
 * @param array   $element   The element to check
 * @param int     $minlength The length to check for
 * @return string            The error message, if the value is invalid.
35
 */
36
function pieform_rule_minlength(Pieform $form, $value, $element, $minlength) {/*{{{*/
37
    if (strlen($value) < $minlength) {
Nigel McNie's avatar
Nigel McNie committed
38
        return sprintf($form->i18n('rule', 'minlength', 'minlength', $element), $minlength);
39
    }
40
}/*}}}*/
41

42
function pieform_rule_minlength_i18n() {/*{{{*/
Nigel McNie's avatar
Nigel McNie committed
43
44
45
    return array(
        'en.utf8' => array(
            'minlength' => 'This field must be at least %d characters long', 
46
47
48
49
        ),
        'de.utf8' => array(
            'minlength' => 'Das Feld muss zumindest %d Zeichen lang sein',
        ),
50
51
52
        'fr.utf8' => array(
            'minlength' => 'Ce champ doit contenir au moins %d caractères',
        ),
53
54
55
        'es.utf8' => array(
            'minlength' => 'Este campo debe tener como mínimo %d caracteres', 
        ),
56
57
58
        'sl.utf8' => array(
            'minlength' => 'To polje mora biti dolgo vsaj %d znakov',
        ),
59
60
61
        'nl.utf8' => array(
            'minlength' => 'Dit veld moet minstens %d tekens lang zijn',
        ),
62
63
64
        'cs.utf8' => array(
            'minlength' => 'Musíte zadat nejméně %d znaků',
        ),
65

Nigel McNie's avatar
Nigel McNie committed
66
    );
67
}/*}}}*/
Nigel McNie's avatar
Nigel McNie committed
68

69
?>