NAME
TValidator - Abstract base class for validator objects
HIERARCHY
TObject
TValidator
SYNOPSIS
use TUI::Validate::Validator;
# Base class for custom validators.
package MyValidator;
use TUI::toolkit;
use TUI::Validate::Validator;
extends TValidator;
sub isValid {
my ( $self, $s ) = @_;
return $s =~ /\A\d+\z/;
}
DESCRIPTION
TValidator defines the common interface used by validation classes in the framework.
It provides the base contract for three validation phases: incremental input checks, final acceptance checks, and optional data transfer handling.
The default implementation is neutral and intended as a superclass; concrete validators specialize behavior for concrete value domains.
Commonly Used Features
Typical subclasses combine isValidInput for live field checking with isValid for final acceptance.
Callers that want a single validation entry point usually use validate, which performs the check and triggers error on failure.
For non-string payloads, subclasses can override transfer to bridge between widget text and structured data.
ATTRIBUTES
options
Read/write bit field for validator options.
status
Read/write status value set by concrete validator implementations.
CONSTRUCTOR
new
Construction is inherited from TObject.
new_TValidator
my $obj = new_TValidator();
Factory helper exported by this module.
METHODS
error
$obj->error();
Hook for reporting validation failures. The base implementation is a no-op.
isValid
my $ok = $obj->isValid($s);
Checks whether a completed value is valid. The base implementation returns true.
isValidInput
my $ok = $obj->isValidInput( $s, $suppressFill );
Checks whether in-progress input is acceptable. The base implementation returns true.
transfer
my $n = $obj->transfer( $s, $buffer, $flags );
Optional data transfer hook. A non-zero return value means the validator handled the transfer operation.
validate
my $ok = $obj->validate($s);
Calls isValid. If validation fails, error is invoked and false is returned.
SEE ALSO
TUI::Validate::Const, TPXPictureValidator, TObject
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).