The following operations are supported. For a formal definition, please review the Service Description.

Web Service Links

Namespace Children of ::wsdb::types::mywebservice::TestDecimal

Namespace Code for ::wsdb::types::mywebservice::TestDecimal

namespace eval ::wsdb::types::mywebservice::TestDecimal {
    variable base xsd::decimal
    variable decimalPointCanon .
    variable fractionDigits 2
    variable maxInclusive 456.78
    variable minExclusive -321.01
    variable totalDigits 5
    variable validate ::wsdb::types::mywebservice::TestDecimal::validate

}

Procedures in ::wsdb::types::mywebservice::TestDecimal


proc ::wsdb::types::mywebservice::TestDecimal::validate {
    value
    {errorListVar }
    {canonListVar }
} {
    variable base
    variable decimalPointCanon
    variable totalDigits
    variable maxInclusive
    variable minExclusive
    variable fractionDigits

    if {"$errorListVar" ne ""} {
        upvar $errorListVar errorList
    }
    if {"$canonListVar" ne ""} {
        upvar $canonListVar canonList
    }

    set valid 0
    set collapsedValue [string trim $value]
    set errorList [list $collapsedValue]
    set canonList [list]

    if {![::wsdb::types::xsd::decimal::ifDecimalCanonize $value canonList $decimalPointCanon decimalList]} {
        lappend errorList "failed decimal test"
        return $valid
    }
    set foundDigits [lindex $decimalList 0]
    set foundFractionDigits [lindex $decimalList 1]
    set canonValue [join $canonList ""]

    while {1} {
        if {![::wsdb::types::${base}::validate $canonValue]} {
            lappend errorList "failed base test $base"
            break
        }
        if {!($canonValue > -321.01)} {
            lappend errorList "failed minExclusive test (-321.01)"
            break
        }
        if {$canonValue > 456.78} {
            lappend errorList "failed maxInclusive test (456.78)"
            break
        }
        if {$foundDigits > $totalDigits} {
            lappend errorList "failed foundDigits ($foundDigits) > totalDigits (5)"
            break
        }
        if {$foundFractionDigits > $fractionDigits} {
            lappend errorList "failed foundFractionDigits ($foundFractionDigits) > fractionDigits (2)"
            break
        }
        set valid 1
        break
    }

    return $valid
}