TABLE OF CONTENTS


::pwtk::checkOTypeStrict_

SYNOPSIS

proc ::pwtk::checkOTypeStrict_ {option value type {typeTxt {}}} {

DESCRIPTION

A strict version of checkOType_, where empty string do not match the type.

type can be: intList, doubleList, type accepted by "string is...."

SOURCE

    if { $typeTxt == {} } {
        set typeTxt $type
    }
    set option -[string trim $option -]
    set err "expected a $typeTxt for the value of the $option option, but got: \"$value\""

    switch -exact -- [lindex $type 0] {
        number -
        numberlist {
            if { ! [eval ::pwtk::type::$type -strict [list $value]] } {
                 uplevel 1 [list ::pwtk::error $err 1]
            }
        }
        range -
        gp_range -
        gp_size -
        intseq -
        rangestring {
            if { $value eq {} || ! [eval ::pwtk::type::$type [list $value]] } {
                uplevel 1 [list ::pwtk::error $err 1]
            }
        }
        optionlist {
            set allowedValues [lrange $type 1 end]
            if { ! [::pwtk::type::optionlist $allowedValues -strict $value] } {
                uplevel 1 [list ::pwtk::error [list "expected one of [join $allowedValues {, }] for the value of the $option option, but got: \"$value\"" 1]
            }
        }
        default {
            if { ! [string is $type -strict $value] } {
                uplevel 1 [list ::pwtk::error $err 1]
            }
        }
    }
}