Changeset 24 in text-formbuilder for trunk/lib/Text/FormBuilder


Ignore:
Timestamp:
11/16/04 14:00:41 (20 years ago)
Author:
peter
Message:

allow for validating but not required fields

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/Text/FormBuilder/grammar

    r23 r24  
    1414        $type, 
    1515        @options, 
     16        $required, 
    1617        $list_var, 
    1718        $size, 
     
    105106            list     => $list_var, 
    106107            validate => $item{'validate(?)'}[0], 
     108            required => $required || 0, 
    107109        }; 
    108110         
     
    121123        } 
    122124         
     125        #warn "field $item{name} is required" if $required; 
     126         
    123127        $type = undef; 
     128        $required = 0; 
    124129        $list_var = undef; 
    125130        $size = undef; 
     
    164169list_var: /@[A-Z_]+/ { $list_var = $item[1] } 
    165170 
    166 option: (simple_multiword | quoted_string) display_text(?) 
     171option: (value | simple_multiword | quoted_string) display_text(?) 
    167172    { push @options, { $item[1] => $item{'display_text(?)'}[0] } } 
    168173 
     
    171176display_text: '[' /[^\]]+/i ']'    { $item[2] } 
    172177 
    173 validate: '//' value 
     178validate: '//' (optional_pattern | required_pattern)    { $item[2] } 
     179 
     180optional_pattern: /[A-Z_]+/ '?' { $required = 0; $item[1] } 
     181 
     182required_pattern: /[A-Z_]+/ { $required = 1; $item[1] } 
    174183 
    175184comment: '#' /.*/ 
Note: See TracChangeset for help on using the changeset viewer.