NAME

TStringLookupValidator - lookup validator backed by a string list

HIERARCHY

TObject
  TValidator
    TLookupValidator
      TStringLookupValidator

SYNOPSIS

use TUI::Validate::StringLookupValidator;

my $v = new_TStringLookupValidator( $stringCollection );

if ( $v->isValid($input) ) {
  # string was found in the configured collection
}

# replace lookup data at runtime
$v->newStringList( $other_collection );

DESCRIPTION

TStringLookupValidator validates input by checking whether the text exists in a configured collection object. The actual lookup happens in lookup, which uses the collection's firstThat method with an exact string comparator (eq). Validation therefore is case-sensitive unless the supplied collection contains normalized values.

This class is a concrete subclass of TLookupValidator and is useful for fields that must match one of a predefined set of tokens.

Commonly Used Features

Typical usage is to build a collection with allowed values and pass it to new_TStringLookupValidator (or new). The field then accepts only strings present in that collection. You can replace the active collection later via newStringList; the previous list is disposed before assignment.

VARIABLES

$errorMsg

our $errorMsg = "Input is not in list of valid strings";

Package-global message shown by error() when validation fails.

ATTRIBUTES

strings

my $list = $v->strings;

Read-only reference to the currently configured lookup collection object. The object is expected to provide firstThat with the callback signature used internally by lookup.

If strings is undef, lookup always returns false.

CONSTRUCTOR

new

my $v = TStringLookupValidator->new( strings => $strings );

Creates a validator bound to the given string collection object. The strings argument is mandatory.

new_TStringLookupValidator

my $v = new_TStringLookupValidator( $aStrings );

Convenience factory with a positional collection argument. Exported by default.

METHODS

error

$v->error();

Displays a modal error message using $errorMsg.

lookup

my $ok = $v->lookup( $string );

Returns true if $string matches an entry in strings by exact equality (eq). Returns false when no collection is configured or when no matching entry is found.

newStringList

$v->newStringList( $strings|undef );

Replaces the active lookup collection. If an existing collection is present, it is disposed via destroy before the new one is stored. Passing undef removes the current list.

SEE ALSO

TLookupValidator, TValidator, TStringCollection

AUTHORS

  • Borland International (original Turbo Vision design)

  • J. Schneider <brickpool@cpan.org> (Perl implementation and maintenance)

COPYRIGHT AND LICENSE

Copyright (c) 1990-1994, 1997 by Borland International

Copyright (c) 2026 the "AUTHORS" as listed above.

This software is licensed under the MIT license (see the LICENSE file, which is part of the distribution).