Changeset 145 for trunk/bin


Ignore:
Timestamp:
Jun 4, 2006 10:56:30 AM (18 years ago)
Author:
scdev
Message:

Q - updated validation module maker to match gettext strings in FormValidator?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/module_maker/validation.cli.php

    r136 r145  
    4848        $type = preg_replace('/^(\w+).*$/', '\\1', $col[1]);
    4949        $is_primary_key = ('PRI' == $col[3]);
    50         $unsigned = preg_match('/\s*unsigned\s*$/i', $col[1]);
     50        $unsigned = preg_match('/\s+unsigned\s*$/i', $col[1]);
    5151
    5252        if (in_array($field, $exclude)) {
     
    5555
    5656        // ----------- isEmpty ------------
    57         $o[] = "\$fv->isEmpty('$field', _(\"<strong>$title</strong> cannot be blank.\"));";
     57        $o[] = "\$fv->notEmpty('$field', sprintf(_(\"%s cannot be blank.\"), _(\"$title\")));";
    5858
    5959        // ----------- stringLength ------------
     
    184184        }
    185185        if ($max_length > 0 && $len_type == 'setenum') {
    186             $o[] = "\$fv->stringLength('$field', 0, $max_length, _(\"<strong>$title</strong> has an invalid selection.\"));";
     186            $o[] = "\$fv->stringLength('$field', 0, $max_length, _(\"$title has an invalid selection.\"));";
    187187        }
    188188        if ($max_length > 0 && $len_type == 'string') {
    189             $o[] = "\$fv->stringLength('$field', 0, $max_length, _(\"<strong>$title</strong> must contain less than " . ($max_length+1) . " characters.\"));";
     189            $o[] = "\$fv->stringLength('$field', 0, $max_length, sprintf(_(\"%s must be %f-to-%f characters in length.\"), _(\"$title\"), 0, $max_length));";
    190190        }
    191191        if ($len_type == 'num') {
    192             $o[] = "\$fv->numericRange('$field', $min, $max, _(\"<strong>$title</strong> must be a valid number between $min and $max.\"));";
     192            $o[] = "\$fv->numericRange('$field', $min, $max, sprintf(_(\"%s must be a number between %f and %f.\"), _(\"$title\"), $min, $max));";
    193193        }
    194194
     
    224224        case 'bigint' :
    225225            $negative_ok = $unsigned ? '' : ', true';
    226             $o[] = "\$fv->isInteger('$field', _(\"<strong>$title</strong> must be an integer.\")$negative_ok);";
     226            $o[] = "\$fv->isInteger('$field', sprintf(_(\"%s must be an integer.\"), _(\"$title\"))$negative_ok);";
    227227            break;
    228228
     
    236236        case 'numeric' :
    237237            $negative_ok = $unsigned ? '' : ', true';
    238             $o[] = "\$fv->isFloat('$field', _(\"<strong>$title</strong> must be a valid number.\")$negative_ok);";
     238            $o[] = "\$fv->isFloat('$field', sprintf(_(\"%s must be a valid number.\"), _(\"$title\"))$negative_ok);";
    239239            break;
    240240
    241241        case 'date' :
    242242        case 'datetime' :
    243             $o[] = "\$fv->validateStrDate('$field', _(\"<strong>$title</strong> must be a valid date in YYYY-MM-DD format.\"));";
    244             $o[] = "\$fv->checkRegex('$field', '/^\d{4}-\d{2}-\d{2}$/', true, _(\"<strong>$title</strong> must be a valid date in YYYY-MM-DD format.\"));";
     243            // \$fv->validateStrDate('$field', sprintf(_(\"%s must be a valid date in YYYY-MM-DD format.\"), _(\"$field\")));
     244            $o[] = "\$fv->validateStrDate('$field', sprintf(_(\"%s must be a valid date in YYYY-MM-DD format.\"), _(\"$field\")));";
     245            $o[] = "\$fv->checkRegex('$field', '/^\d{4}-\d{2}-\d{2}$/', true, sprintf(_(\"%s must be in YYYY-MM-DD format.\"), _(\"$field\")));";
    245246            break;
    246247
    247248        case 'timestamp' :
    248             $o[] = "\$fv->checkRegex('$field', '/^\d{14}$/', true, _(\"<strong>$title</strong> must be a valid mysql timestamp in YYYYMMDDhhmmss format.\"));";
     249            $o[] = "\$fv->checkRegex('$field', '/^\d{14}$/', true, sprintf(_(\"%s must be a valid mysql timestamp in YYYYMMDDhhmmss format.\"), _(\"$field\")));";
    249250            break;
    250251
    251252        case 'time' :
    252             $o[] = "\$fv->checkRegex('$field', '/^\d{1,3}:\d{2}:\d{2}$/', true, _(\"<strong>$title</strong> must be a valid time in hh:mm:ss format.\"));";
     253            $o[] = "\$fv->checkRegex('$field', '/^\d{1,3}:\d{2}:\d{2}$/', true, sprintf(_(\"%s must be a valid time in hh:mm:ss format.\"), _(\"$field\")));";
    253254            break;
    254255
    255256        case 'year' :
    256             $o[] = "\$fv->checkRegex('$field', '/^\d{4}$/', true, _(\"<strong>$title</strong> must be a valid year in YYYY format.\"));";
     257            $o[] = "\$fv->checkRegex('$field', '/^\d{4}$/', true, sprintf(_(\"%s must be a valid year in YYYY format.\"), _(\"$field\")));";
    257258            break;
    258259
Note: See TracChangeset for help on using the changeset viewer.