NAME
Return::Set - Return a value optionally validated against a strict schema
VERSION
Version 0.05
SYNOPSIS
use Return::Set qw(set_return);
return set_return($value);
return set_return($value, { type => 'integer' });
return set_return({ output => $value, schema => { type => 'integer' } });
DESCRIPTION
If a validation schema is provided, the value is validated using Params::Validate::Strict. If validation fails, it croaks.
When used hand-in-hand with Params::Get, you should be able to formally specify the input and output sets for a method.
Exports a single function, set_return, which returns a given value.
FUNCTIONS
set_return
Returns the given value, optionally validating it against a schema.
Three calling forms are accepted:
- set_return($value)
-
Returns
$valueimmediately with no validation. - set_return($value, $schema)
-
Returns
$valueafter validating it against$schema(a Params::Validate::Strict schema hashref, e.g.{ type => 'integer' }). Croaks if validation fails. - set_return(\%args)
-
Named-parameter form.
%argsmay containoutput(preferred) orvalue(accepted for backwards compatibility) for the return value, andschemafor the optional schema. Croaks if validation fails.
AUTHOR
Nigel Horne, <njh at nigelhorne.com>
SEE ALSO
SUPPORT
This module is provided as-is without any warranty.
LICENCE AND COPYRIGHT
Copyright 2025-2026 Nigel Horne.
Usage is subject to the GPL2 licence terms. If you use it, please let me know.