source: trunk/lang/tcl/scripts/validations/size.tcl @ 3177

Last change on this file since 3177 was 3177, checked in by mmc, 12 years ago

Updated all of the copyright notices to reference the transfer to
the new HUBzero Foundation, LLC.

File size: 916 bytes
Line 
1# ----------------------------------------------------------------------
2#  VALIDATION: size
3#
4#  Handles the string:validate=size setting for an object attribute.
5#  Checks the given string to see if it is a valid size for a <string>
6#  object.  Returns an error if something is wrong.
7# ======================================================================
8#  AUTHOR:  Michael McLennan, Purdue University
9#  Copyright (c) 2004-2012  HUBzero Foundation, LLC
10#
11#  See the file "license.terms" for information on usage and
12#  redistribution of this file, and for a DISCLAIMER OF ALL WARRANTIES.
13# ======================================================================
14proc validate_size {str} {
15    switch -regexp -- $str {
16        ^$ - ^[0-9]+$ - ^[0-9]+x[0-9]+$ - binary {
17            return "ok"
18        }
19        default {
20            error "bad size \"$str\": should be WW or WWxHH or binary"
21        }
22    }
23}
Note: See TracBrowser for help on using the repository browser.