NAME

HTML::Tested::Value - Base class for most HTML::Tested widgets.

DESCRIPTION

This class provides the most basic HTML::Tested widget - simple value to be output in the template.

METHODS

$widget->name

Returns the name of the widget.

$widget->options

Returns hash of options assigned to this widget. See OPTIONS section for description of available options.

$widget->value_to_string($name, $val, $caller, $stash)

This function is called from render to return final string which will be rendered into stash. For HTML::Tested::Value it simply returns $val.

$caller is the object calling this function. $stash is read-only hash of the values accummulated so far.

$widget->encode_value($val)

Uses HTML::Entities to encode $val.

$widget->get_value($caller, $id)

It is called from $widget->render to get the value to render.

$widget->seal_value($value, $caller)

If is_sealed option is used, this function is called from $widget->render to seal the value before putting it to stash. See HTML::Tested::Seal for sealing description.

This function maintains cache of sealed values in caller. Thus promising that the same value will map to the same id during request.

$widget->render($caller, $stash, $id)

Renders widget into $stash. For HTML::Tested::Value it essentially means assigning $stash->{ $widget->name } with $widget->get_value.

$widget->push_constraint($constraint)

$constraint should be ARRAY reference with the following format:

[ TYPE, OP, COOKIE ]

where TYPE is type of the constraint, OP is the operation to be done on the constraint and cookie is optional method for the application to recognize specific constraint.

Available types are: regexp - with OP being regexp string (e.g. [ regexp => '\d+' ]. defined - OP doesn't matter here (e.g. [ defined => '' ].

$widget->validate($value, $caller)

Validate value returning list of failed constraints in the format specified above.

I.e. the $value is "constraint-clean" when validate returns empty list.

Validate is disabled if no_validate widget option is set.

$widget->absorb_one_value($parent, $val, @path)

Parses $val and puts the result into $parent object. @path is used for widgets aggregating other widgets (such as HTML::Tested::List).

AUTHOR

Boris Sukholitko (boriss@gmail.com)

COPYRIGHT

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

The full text of the license can be found in the LICENSE file included with this module.

SEE ALSO

HTML::Tested