template::data::validate::currency (public)
template::data::validate::currency value_ref message_ref
Defined in packages/acs-templating/tcl/currency-procs.tcl
form validation for currency type. Should validate according to locale for example, the following forms: "$2.03" "Rs 50.42" "12.52L" "Y5,13c"
- Parameters:
- value_ref (required)
- Reference variable to the submitted value
- message_ref (required)
- Reference variable for returning error messages
- Returns:
- true (1) if valid, false (0) if not
- Partial Call Graph (max 5 caller/called nodes):
- Testcases:
- validate_currency
Source code: upvar 2 $message_ref message $value_ref value # a currency is a 6 element list supporting, for example, the following forms: "$2.03" "Rs 50.42" "12.52L" "Y5,13c" # equivalent of date::unpack lassign $value leading_symbol whole_part separator fractional_part trailing_money format set format_whole_part [lindex $format 1] set format_fractional_part [lindex $format 3] set whole_part_valid_p [template::data::validate integer whole_part message] if { $fractional_part ne "" } { set fractional_part_valid_p [template::data::validate integer fractional_part message] } else { set fractional_part_valid_p 1 } if { ! $whole_part_valid_p || ! $fractional_part_valid_p } { set message "[_ acs-templating.Invalid_currency] [join [lrange $value 0 4] ""]" return 0 } else { return 1 }XQL Not present: Generic, PostgreSQL, Oracle