NAME

Venus::Check - Check Class

ABSTRACT

Check Class for Perl 5

SYNOPSIS

package main;

use Venus::Check;

my $check = Venus::Check->new;

# $check->float;

# my $result = $check->result(rand);

# 0.1234567890

DESCRIPTION

This package provides a mechanism for performing runtime dynamic type checking on data.

ATTRIBUTES

This package has the following attributes:

on_eval

on_eval(within[arrayref, coderef] $data) (within[arrayref, coderef])

The on_eval attribute is read-write, accepts (ArrayRef[CodeRef]) values, and is optional.

Since 3.55

on_eval example 1
# given: synopsis

package main;

my $set_on_eval = $check->on_eval([sub{1}]);

# [sub{1}]
on_eval example 2
# given: synopsis

# given: example-1 on_eval

package main;

my $get_on_eval = $check->on_eval;

# [sub{1}]

INHERITS

This package inherits behaviors from:

Venus::Kind::Utility

INTEGRATES

This package integrates behaviors from:

Venus::Role::Buildable

METHODS

This package provides the following methods:

accept

accept(string $name, string | within[arrayref, string] @args) (Venus::Check)

The accept method configures the object to accept the conditions or identity provided and returns the invocant. This method dispatches to the method(s) specified, or to the "identity" method otherwise.

Since 3.55

accept example 1
# given: synopsis

package main;

$check = $check->accept('string');

# bless(..., 'Venus::Check')

# my $result = $check->eval('okay');

# true
accept example 2
# given: synopsis

package main;

$check = $check->accept('string');

# bless(..., 'Venus::Check')

# my $result = $check->eval(12345);

# false
accept example 3
# given: synopsis

package main;

$check = $check->accept('string');

# bless(..., 'Venus::Check')

# my $result = $check->result('okay');

# 'okay'
accept example 4
# given: synopsis

package main;

$check = $check->accept('string');

# bless(..., 'Venus::Check')

# my $result = $check->result(12345);

# Exception! (isa Venus::Check::Error) (see error_on_coded)

any

any() (Venus::Check)

The any method configures the object to accept any value and returns the invocant.

Since 3.55

any example 1
# given: synopsis

package main;

$check = $check->any;

# bless(..., 'Venus::Check')

# my $result = $check->eval(1);

# true
any example 2
# given: synopsis

package main;

$check = $check->any;

# bless(..., 'Venus::Check')

# my $result = $check->eval(bless{});

# true

array

array(coderef @code) (Venus::Check)

The array method configures the object to accept array references and returns the invocant.

Since 3.55

array example 1
# given: synopsis

package main;

$check = $check->array;

# bless(..., 'Venus::Check')

# my $result = $check->eval([]);

# true
array example 2
# given: synopsis

package main;

$check = $check->array;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# false
array example 3
# given: synopsis

package main;

$check = $check->array;

# bless(..., 'Venus::Check')

# my $result = $check->result([1..4]);

# [1..4]
array example 4
# given: synopsis

package main;

$check = $check->array;

# bless(..., 'Venus::Check')

# my $result = $check->result({1..4});

# Exception! (isa Venus::Check::Error) (see error_on_coded)

arrayref

arrayref(coderef @code) (Venus::Check)

The arrayref method configures the object to accept array references and returns the invocant.

Since 3.55

arrayref example 1
# given: synopsis

package main;

$check = $check->arrayref;

# bless(..., 'Venus::Check')

# my $result = $check->eval([]);

# true
arrayref example 2
# given: synopsis

package main;

$check = $check->arrayref;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# false
arrayref example 3
# given: synopsis

package main;

$check = $check->arrayref;

# bless(..., 'Venus::Check')

# my $result = $check->result([1..4]);

# [1..4]
arrayref example 4
# given: synopsis

package main;

$check = $check->arrayref;

# bless(..., 'Venus::Check')

# my $result = $check->result({1..4});

# Exception! (isa Venus::Check::Error) (see error_on_coded)

attributes

attributes(string | within[arrayref, string] @args) (Venus::Check)

The attributes method configures the object to accept objects containing attributes whose values' match the attribute names and types specified, and returns the invocant.

Since 3.55

attributes example 1
# given: synopsis

package Example;

use Venus::Class 'attr';

attr 'name';

package main;

$check = $check->attributes('name', 'string');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Example->new(name => 'test'));

# true
attributes example 2
# given: synopsis

package Example;

use Venus::Class 'attr';

attr 'name';

package main;

$check = $check->attributes('name', 'string');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Example->new);

# false
attributes example 3
# given: synopsis

package Example;

use Venus::Class 'attr';

attr 'name';

package main;

$check = $check->attributes('name', 'string');

# bless(..., 'Venus::Check')

# my $result = $check->result(Example->new(name => 'test'));

# bless(..., 'Example')
attributes example 4
# given: synopsis

package Example;

use Venus::Class 'attr';

attr 'name';

package main;

$check = $check->attributes('name', 'string');

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)
attributes example 5
# given: synopsis

package Example;

use Venus::Class 'attr';

attr 'name';

package main;

$check = $check->attributes('name', 'string', 'age');

# bless(..., 'Venus::Check')

# my $result = $check->result(Example->new);

# Exception! (isa Venus::Check::Error) (see error_on_pairs)
attributes example 6
# given: synopsis

package Example;

use Venus::Class;

package main;

$check = $check->attributes('name', 'string');

# bless(..., 'Venus::Check')

# my $result = $check->result(Example->new);

# Exception! (isa Venus::Check::Error) (see error_on_missing)
attributes example 7
# given: synopsis

package Example;

use Venus::Class 'attr';

attr 'name';

package main;

$check = $check->attributes('name', 'string');

# bless(..., 'Venus::Check')

# my $result = $check->result(Example->new(name => rand));

# Exception! (isa Venus::Check::Error) (see error_on_coded)

bool

bool(coderef @code) (Venus::Check)

The bool method configures the object to accept boolean values and returns the invocant.

Since 3.55

bool example 1
# given: synopsis

package main;

use Venus;

$check = $check->bool;

# bless(..., 'Venus::Check')

# my $result = $check->eval(true);

# true
bool example 2
# given: synopsis

package main;

use Venus;

$check = $check->bool;

# bless(..., 'Venus::Check')

# my $result = $check->eval(1);

# false
bool example 3
# given: synopsis

package main;

use Venus;

$check = $check->bool;

# bless(..., 'Venus::Check')

# my $result = $check->result(true);

# true
bool example 4
# given: synopsis

package main;

use Venus;

$check = $check->bool;

# bless(..., 'Venus::Check')

# my $result = $check->result(1);

# Exception! (isa Venus::Check::Error) (see error_on_coded)

boolean

boolean(coderef @code) (Venus::Check)

The boolean method configures the object to accept boolean values and returns the invocant.

Since 3.55

boolean example 1
# given: synopsis

package main;

use Venus;

$check = $check->boolean;

# bless(..., 'Venus::Check')

# my $result = $check->eval(true);

# true
boolean example 2
# given: synopsis

package main;

use Venus;

$check = $check->boolean;

# bless(..., 'Venus::Check')

# my $result = $check->eval(1);

# false
boolean example 3
# given: synopsis

package main;

use Venus;

$check = $check->boolean;

# bless(..., 'Venus::Check')

# my $result = $check->result(true);

# true
boolean example 4
# given: synopsis

package main;

use Venus;

$check = $check->boolean;

# bless(..., 'Venus::Check')

# my $result = $check->result(1);

# Exception! (isa Venus::Check::Error) (see error_on_coded)

branch

branch(string @args) (Venus::Check)

The branch method returns a new Venus::Check object configured to evaluate a branch of logic from its source.

Since 3.55

branch example 1
# given: synopsis

package main;

my $branch = $check->branch('nested');

# bless(..., 'Venus::Check')

clear

clear() (Venus::Check)

The clear method resets all registered conditions and returns the invocant.

Since 3.55

clear example 1
# given: synopsis

package main;

$check->any;

$check = $check->clear;

# bless(..., 'Venus::Check')

code

code(coderef @code) (Venus::Check)

The code method configures the object to accept code references and returns the invocant.

Since 3.55

code example 1
# given: synopsis

package main;

$check = $check->code;

# bless(..., 'Venus::Check')

# my $result = $check->eval(sub{});

# true
code example 2
# given: synopsis

package main;

$check = $check->code;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# false
code example 3
# given: synopsis

package main;

$check = $check->code;

# bless(..., 'Venus::Check')

# my $result = $check->result(sub{});

# sub{}
code example 4
# given: synopsis

package main;

$check = $check->code;

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)

coded

coded(any $data, string $name) (Venus::Check)

The coded method accepts a value and a type name returns the result of a "coded" in Venus::What operation.

Since 3.55

coded example 1
# given: synopsis

package main;

$check = $check->coded('hello', 'string');

# true
coded example 2
# given: synopsis

package main;

$check = $check->coded(12345, 'string');

# false

coderef

coderef(coderef @code) (Venus::Check)

The coderef method configures the object to accept code references and returns the invocant.

Since 3.55

coderef example 1
# given: synopsis

package main;

$check = $check->coderef;

# bless(..., 'Venus::Check')

# my $result = $check->eval(sub{});

# true
coderef example 2
# given: synopsis

package main;

$check = $check->coderef;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# false
coderef example 3
# given: synopsis

package main;

$check = $check->coderef;

# bless(..., 'Venus::Check')

# my $result = $check->result(sub{});

# sub{}
coderef example 4
# given: synopsis

package main;

$check = $check->coderef;

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)

consumes

consumes(string $role) (Venus::Check)

The consumes method configures the object to accept objects which consume the role provided, and returns the invocant.

Since 3.55

consumes example 1
# given: synopsis

package Example;

use Venus::Class 'base';

base 'Venus::Kind';

package main;

$check = $check->consumes('Venus::Role::Throwable');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Example->new);

# true
consumes example 2
# given: synopsis

package Example;

use Venus::Class 'base';

base 'Venus::Kind';

package main;

$check = $check->consumes('Venus::Role::Knowable');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Example->new);

# false
consumes example 3
# given: synopsis

package Example;

use Venus::Class 'base';

base 'Venus::Kind';

package main;

$check = $check->consumes('Venus::Role::Throwable');

# bless(..., 'Venus::Check')

# my $result = $check->result(Example->new);

# bless(..., 'Example')
consumes example 4
# given: synopsis

package main;

$check = $check->consumes('Venus::Role::Knowable');

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)
consumes example 5
# given: synopsis

package Example;

use Venus::Class 'base';

base 'Venus::Kind';

package main;

$check = $check->consumes('Venus::Role::Knowable');

# bless(..., 'Venus::Check')

# my $result = $check->result(Example->new);

# Exception! (isa Venus::Check::Error) (see error_on_consumes)

defined

defined(coderef @code) (Venus::Check)

The defined method configures the object to accept any value that's not undefined and returns the invocant.

Since 3.55

defined example 1
# given: synopsis

package main;

$check = $check->defined;

# bless(..., 'Venus::Check')

# my $result = $check->eval('');

# true
defined example 2
# given: synopsis

package main;

$check = $check->defined;

# bless(..., 'Venus::Check')

# my $result = $check->eval(undef);

# false
defined example 3
# given: synopsis

package main;

$check = $check->defined;

# bless(..., 'Venus::Check')

# my $result = $check->result('');

# ''
defined example 4
# given: synopsis

package main;

$check = $check->defined;

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)

dirhandle

dirhandle(coderef @code) (Venus::Check)

The dirhandle method configures the object to accept dirhandles and returns the invocant.

Since 4.15

dirhandle example 1
# given: synopsis

package main;

$check = $check->dirhandle;

# bless(..., 'Venus::Check')

# opendir my $dh, './t';

# my $result = $check->eval($dh);

# true
dirhandle example 2
# given: synopsis

package main;

$check = $check->dirhandle;

# bless(..., 'Venus::Check')

# opendir my $dh, './xyz';

# my $result = $check->eval($dh);

# false
dirhandle example 3
# given: synopsis

package main;

$check = $check->dirhandle;

# bless(..., 'Venus::Check')

# opendir my $dh, './t';

# my $result = $check->result($dh);

# \*{'::$dh'}
dirhandle example 4
# given: synopsis

package main;

$check = $check->dirhandle;

# bless(..., 'Venus::Check')

# opendir my $dh, './xyz';

# my $result = $check->result($dh);

# Exception! (isa Venus::Check::Error) (see error_on_dirhandle)

either

either(string | within[arrayref, string] @args) (Venus::Check)

The either method configures the object to accept "either" of the conditions provided, which may be a string or arrayref representing a method call, and returns the invocant.

Since 3.55

either example 1
# given: synopsis

package main;

$check = $check->either('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->eval('hello');

# true
either example 2
# given: synopsis

package main;

$check = $check->either('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->eval(rand);

# false
either example 3
# given: synopsis

package main;

$check = $check->either('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->result('hello');

# 'hello'
either example 4
# given: synopsis

package main;

$check = $check->either('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->result(rand);

# Exception! (isa Venus::Check::Error) (see error_on_either)

enum

enum(string @args) (Venus::Check)

The enum method configures the object to accept any one of the provide options, and returns the invocant.

Since 3.55

enum example 1
# given: synopsis

package main;

$check = $check->enum('black', 'white', 'grey');

# bless(..., 'Venus::Check')

# my $result = $check->eval('black');

# true
enum example 2
# given: synopsis

package main;

$check = $check->enum('black', 'white', 'grey');

# bless(..., 'Venus::Check')

# my $result = $check->eval('purple');

# false
enum example 3
# given: synopsis

package main;

$check = $check->enum('black', 'white', 'grey');

# bless(..., 'Venus::Check')

# my $result = $check->result('black');

# 'black'
enum example 4
# given: synopsis

package main;

$check = $check->enum('black', 'white', 'grey');

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)
enum example 5
# given: synopsis

package main;

$check = $check->enum('black', 'white', 'grey');

# bless(..., 'Venus::Check')

# my $result = $check->result('purple');

# Exception! (isa Venus::Check::Error) (see error_on_enum)

eval

eval(any $data) (any)

The eval method returns true or false if the data provided passes the registered conditions.

Since 3.55

eval example 1
# given: synopsis

package main;

my $eval = $check->eval;

# false
eval example 2
# given: synopsis

package main;

my $eval = $check->any->eval('');

# true

evaled

evaled() (boolean)

The evaled method returns true if "eval" has previously been executed, and false otherwise.

Since 3.35

evaled example 1
# given: synopsis

package main;

my $evaled = $check->evaled;

# false
evaled example 2
# given: synopsis

package main;

$check->any->eval;

my $evaled = $check->evaled;

# true

evaler

evaler(any @args) (coderef)

The evaler method returns a coderef which calls the "eval" method with the invocant when called.

Since 3.55

evaler example 1
# given: synopsis

package main;

my $evaler = $check->evaler;

# sub{...}

# my $result = $evaler->();

# false
evaler example 2
# given: synopsis

package main;

my $evaler = $check->any->evaler;

# sub{...}

# my $result = $evaler->();

# true

fail

fail(any $data, hashref $meta) (boolean)

The fail method captures data related to a failure and returns false.

Since 3.55

fail example 1
# given: synopsis

package main;

my $fail = $check->fail('...', {
  from => 'caller',
});

# false

failed

failed() (boolean)

The failed method returns true if the result of the last operation was a failure, otherwise returns false.

Since 3.55

failed example 1
# given: synopsis

package main;

my $failed = $check->failed;

# false
failed example 2
# given: synopsis

package main;

$check->string->eval(12345);

my $failed = $check->failed;

# true
failed example 3
# given: synopsis

package main;

$check->string->eval('hello');

my $failed = $check->failed;

# false

filehandle

filehandle(coderef @code) (Venus::Check)

The filehandle method configures the object to accept filehandles and returns the invocant.

Since 4.15

filehandle example 1
# given: synopsis

package main;

$check = $check->filehandle;

# bless(..., 'Venus::Check')

# open my $fh, './t/Venus.t';

# my $result = $check->eval($fh);

# true
filehandle example 2
# given: synopsis

package main;

$check = $check->filehandle;

# bless(..., 'Venus::Check')

# open my $fh, './xyz/Venus.t';

# my $result = $check->eval($fh);

# false
filehandle example 3
# given: synopsis

package main;

$check = $check->filehandle;

# bless(..., 'Venus::Check')

# open my $fh, './t/Venus.t';

# my $result = $check->result($fh);

# \*{'::$fh'}
filehandle example 4
# given: synopsis

package main;

$check = $check->filehandle;

# bless(..., 'Venus::Check')

# open my $fh, './xyz/Venus.t';

# my $result = $check->result($fh);

# Exception! (isa Venus::Check::Error) (see error_on_filehandle)

float

float(coderef @code) (Venus::Check)

The float method configures the object to accept floating-point values and returns the invocant.

Since 3.55

float example 1
# given: synopsis

package main;

$check = $check->float;

# bless(..., 'Venus::Check')

# my $result = $check->eval(1.2345);

# true
float example 2
# given: synopsis

package main;

$check = $check->float;

# bless(..., 'Venus::Check')

# my $result = $check->eval(12345);

# false
float example 3
# given: synopsis

package main;

$check = $check->float;

# bless(..., 'Venus::Check')

# my $result = $check->result(1.2345);

# 1.2345
float example 4
# given: synopsis

package main;

$check = $check->float;

# bless(..., 'Venus::Check')

# my $result = $check->result(12345);

# Exception! (isa Venus::Check::Error) (see error_on_coded)

glob

glob(coderef @code) (Venus::Check)

The glob method configures the object to accept typeglobs and returns the invocant.

Since 4.15

glob example 1
# given: synopsis

package main;

$check = $check->glob;

# bless(..., 'Venus::Check')

# my $result = $check->eval(\*main);

# true
glob example 2
# given: synopsis

package main;

$check = $check->glob;

# bless(..., 'Venus::Check')

# my $result = $check->eval(*main);

# false
glob example 3
# given: synopsis

package main;

$check = $check->glob;

# bless(..., 'Venus::Check')

# my $result = $check->result(\*main);

# \*::main
glob example 4
# given: synopsis

package main;

$check = $check->glob;

# bless(..., 'Venus::Check')

# my $result = $check->result(*main);

# Exception! (isa Venus::Check::Error) (see error_on_typeglob)

hash

hash(coderef @code) (Venus::Check)

The hash method configures the object to accept hash references and returns the invocant.

Since 3.55

hash example 1
# given: synopsis

package main;

$check = $check->hash;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# true
hash example 2
# given: synopsis

package main;

$check = $check->hash;

# bless(..., 'Venus::Check')

# my $result = $check->eval([]);

# false
hash example 3
# given: synopsis

package main;

$check = $check->hash;

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# {}
hash example 4
# given: synopsis

package main;

$check = $check->hash;

# bless(..., 'Venus::Check')

# my $result = $check->result([]);

# Exception! (isa Venus::Check::Error) (see error_on_coded)

hashkeys

hashkeys(string | within[arrayref, string] @args) (Venus::Check)

The hashkeys method configures the object to accept hash based values containing the keys whose values' match the specified types, and returns the invocant.

Since 3.55

hashkeys example 1
# given: synopsis

package main;

$check = $check->hashkeys('rand', 'float');

# bless(..., 'Venus::Check')

# my $result = $check->eval({rand => rand});

# true
hashkeys example 2
# given: synopsis

package main;

$check = $check->hashkeys('rand', 'float');

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# false
hashkeys example 3
# given: synopsis

package main;

$check = $check->hashkeys('rand', 'float');

# bless(..., 'Venus::Check')

# my $result = $check->result({rand => rand});

# {rand => rand}
hashkeys example 4
# given: synopsis

package main;

$check = $check->hashkeys('rand', 'float');

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)
hashkeys example 5
# given: synopsis

package main;

$check = $check->hashkeys('rand', 'float');

# bless(..., 'Venus::Check')

# my $result = $check->result([]);

# Exception! (isa Venus::Check::Error) (see error_on_hashref)
hashkeys example 6
# given: synopsis

package main;

$check = $check->hashkeys('rand', 'float', 'name');

# bless(..., 'Venus::Check')

# my $result = $check->result({rand => rand});

# Exception! (isa Venus::Check::Error) (see error_on_pairs)
hashkeys example 7
# given: synopsis

package main;

$check = $check->hashkeys('rand', 'float');

# bless(..., 'Venus::Check')

# my $result = $check->result({rndm => rand});

# Exception! (isa Venus::Check::Error) (see error_on_missing)

hashref

hashref(coderef @code) (Venus::Check)

The hashref method configures the object to accept hash references and returns the invocant.

Since 3.55

hashref example 1
# given: synopsis

package main;

$check = $check->hashref;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# true
hashref example 2
# given: synopsis

package main;

$check = $check->hashref;

# bless(..., 'Venus::Check')

# my $result = $check->eval([]);

# false
hashref example 3
# given: synopsis

package main;

$check = $check->hashref;

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# {}
hashref example 4
# given: synopsis

package main;

$check = $check->hashref;

# bless(..., 'Venus::Check')

# my $result = $check->result([]);

# Exception! (isa Venus::Check::Error) (see error_on_coded)

identity

identity(string $name) (Venus::Check)

The identity method configures the object to accept objects of the type specified as the argument, and returns the invocant.

Since 3.55

identity example 1
# given: synopsis

package main;

$check = $check->identity('Venus::Check');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Check->new);

# true
identity example 2
# given: synopsis

package main;

use Venus::Config;

$check = $check->identity('Venus::Check');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Config->new);

# false
identity example 3
# given: synopsis

package main;

$check = $check->identity('Venus::Check');

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Check->new);

# bless(..., 'Venus::Check')
identity example 4
# given: synopsis

package main;

$check = $check->identity('Venus::Check');

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)
identity example 5
# given: synopsis

package main;

use Venus::Config;

$check = $check->identity('Venus::Check');

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Config->new);

# Exception! (isa Venus::Check::Error) (see error_on_identity)

includes

includes(string | within[arrayref, string] @args) (Venus::Check)

The include method configures the object to accept "all" of the conditions provided, which may be a string or arrayref representing a method call, and returns the invocant.

Since 3.55

includes example 1
# given: synopsis

package main;

$check = $check->includes('string', 'yesno');

# bless(..., 'Venus::Check')

# my $result = $check->eval('yes');

# true
includes example 2
# given: synopsis

package main;

$check = $check->includes('string', 'yesno');

# bless(..., 'Venus::Check')

# my $result = $check->eval(0);

# false
includes example 3
# given: synopsis

package main;

$check = $check->includes('string', 'yesno');

# bless(..., 'Venus::Check')

# my $result = $check->result('Yes');

# 'Yes'
includes example 4
# given: synopsis

package main;

$check = $check->includes('string', 'yesno');

# bless(..., 'Venus::Check')

# my $result = $check->result(1);

# Exception! (isa Venus::Check::Error) (see error_on_includes)

inherits

inherits(string $base) (Venus::Check)

The inherits method configures the object to accept objects of the type specified as the argument, and returns the invocant. This method is a proxy for the "identity" method.

Since 3.55

inherits example 1
# given: synopsis

package main;

$check = $check->inherits('Venus::Kind::Utility');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Check->new);

# true
inherits example 2
# given: synopsis

package main;

$check = $check->inherits('Venus::Kind::Value');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Check->new);

# false
inherits example 3
# given: synopsis

package main;

$check = $check->inherits('Venus::Kind::Utility');

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Check->new);

# bless(..., 'Venus::Check')
inherits example 4
# given: synopsis

package main;

$check = $check->inherits('Venus::Kind::Value');

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)
inherits example 5
# given: synopsis

package main;

$check = $check->inherits('Venus::Kind::Value');

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Check->new);

# Exception! (isa Venus::Check::Error) (see error_on_inherits)

integrates

integrates(string $role) (Venus::Check)

The integrates method configures the object to accept objects that support the "does" behavior and consumes the "role" specified as the argument, and returns the invocant.

Since 3.55

integrates example 1
# given: synopsis

package main;

$check = $check->integrates('Venus::Role::Throwable');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Check->new);

# true
integrates example 2
# given: synopsis

package main;

$check = $check->integrates('Venus::Role::Knowable');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Check->new);

# false
integrates example 3
# given: synopsis

package main;

$check = $check->integrates('Venus::Role::Throwable');

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Check->new);

# bless(..., 'Venus::Check')
integrates example 4
# given: synopsis

package main;

$check = $check->integrates('Venus::Role::Knowable');

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)
integrates example 5
# given: synopsis

package main;

$check = $check->integrates('Venus::Role::Knowable');

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Check->new);

# Exception! (isa Venus::Check::Error) (see error_on_consumes)

maybe

maybe(string | within[arrayref, string] @args) (Venus::Check)

The maybe method configures the object to accept the type provided as an argument, or undef, and returns the invocant.

Since 3.55

maybe example 1
# given: synopsis

package main;

$check = $check->maybe('string');

# bless(..., 'Venus::Check')

# my $result = $check->eval('');

# true
maybe example 2
# given: synopsis

package main;

$check = $check->maybe('string');

# bless(..., 'Venus::Check')

# my $result = $check->eval([]);

# false
maybe example 3
# given: synopsis

package main;

$check = $check->maybe('string');

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# undef
maybe example 4
# given: synopsis

package main;

$check = $check->maybe('string');

# bless(..., 'Venus::Check')

# my $result = $check->result(0);

# Exception! (isa Venus::Check::Error) (see error_on_either)
maybe example 5
# given: synopsis

package main;

$check = $check->maybe('string');

# bless(..., 'Venus::Check')

# my $result = $check->result([]);

# Exception! (isa Venus::Check::Error) (see error_on_either)

new

new(any @args) (Venus::Check)

The new method constructs an instance of the package.

Since 4.15

new example 1
package main;

use Venus::Check;

my $new = Venus::Check->new;

# bless(..., "Venus::Check")

number

number(coderef @code) (Venus::Check)

The number method configures the object to accept numberic values and returns the invocant.

Since 3.55

number example 1
# given: synopsis

package main;

$check = $check->number;

# bless(..., 'Venus::Check')

# my $result = $check->eval(1234);

# true
number example 2
# given: synopsis

package main;

$check = $check->number;

# bless(..., 'Venus::Check')

# my $result = $check->eval(1.234);

# false
number example 3
# given: synopsis

package main;

$check = $check->number;

# bless(..., 'Venus::Check')

# my $result = $check->result(1234);

# 1234
number example 4
# given: synopsis

package main;

$check = $check->number;

# bless(..., 'Venus::Check')

# my $result = $check->result(1.234);

# Exception! (isa Venus::Check::Error) (see error_on_coded)

object

object(coderef @code) (Venus::Check)

The object method configures the object to accept objects and returns the invocant.

Since 3.55

object example 1
# given: synopsis

package main;

$check = $check->object;

# bless(..., 'Venus::Check')

# my $result = $check->eval(bless{});

# true
object example 2
# given: synopsis

package main;

$check = $check->object;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# false
object example 3
# given: synopsis

package main;

$check = $check->object;

# bless(..., 'Venus::Check')

# my $result = $check->result(bless{});

# bless{}
object example 4
# given: synopsis

package main;

$check = $check->object;

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)

package

package(coderef @code) (Venus::Check)

The package method configures the object to accept package names (which are loaded) and returns the invocant.

Since 3.55

package example 1
# given: synopsis

package main;

$check = $check->package;

# bless(..., 'Venus::Check')

# my $result = $check->eval('Venus::Check');

# true
package example 2
# given: synopsis

package main;

$check = $check->package;

# bless(..., 'Venus::Check')

# my $result = $check->eval('MyApp::Check');

# false
package example 3
# given: synopsis

package main;

$check = $check->package;

# bless(..., 'Venus::Check')

# my $result = $check->result('Venus::Check');

# 'Venus::Check'
package example 4
# given: synopsis

package main;

$check = $check->package;

# bless(..., 'Venus::Check')

# my $result = $check->result(0);

# Exception! (isa Venus::Check::Error) (see error_on_coded)
package example 5
# given: synopsis

package main;

$check = $check->package;

# bless(..., 'Venus::Check')

# my $result = $check->result('main');

# Exception! (isa Venus::Check::Error) (see error_on_package)
package example 6
# given: synopsis

package main;

$check = $check->package;

# bless(..., 'Venus::Check')

# my $result = $check->result('MyApp::Check');

# Exception! (isa Venus::Check::Error) (see error_on_package_loaded)

pass

pass(any $data, hashref $meta) (boolean)

The pass method captures data related to a success and returns true.

Since 3.55

pass example 1
# given: synopsis

package main;

my $pass = $check->pass('...', {
  from => 'caller',
});

# true

passed

passed() (boolean)

The passed method returns true if the result of the last operation was a success, otherwise returns false.

Since 3.55

passed example 1
# given: synopsis

package main;

my $passed = $check->passed;

# false
passed example 2
# given: synopsis

package main;

$check->string->eval('hello');

my $passed = $check->passed;

# true
passed example 3
# given: synopsis

package main;

$check->string->eval(12345);

my $passed = $check->passed;

# false

reference

reference(coderef @code) (Venus::Check)

The reference method configures the object to accept references and returns the invocant.

Since 3.55

reference example 1
# given: synopsis

package main;

$check = $check->reference;

# bless(..., 'Venus::Check')

# my $result = $check->eval([]);

# true
reference example 2
# given: synopsis

package main;

$check = $check->reference;

# bless(..., 'Venus::Check')

# my $result = $check->eval('');

# false
reference example 3
# given: synopsis

package main;

$check = $check->reference;

# bless(..., 'Venus::Check')

# my $result = $check->result([]);

# []
reference example 4
# given: synopsis

package main;

$check = $check->reference;

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)
reference example 5
# given: synopsis

package main;

$check = $check->reference;

# bless(..., 'Venus::Check')

# my $result = $check->result('');

# Exception! (isa Venus::Check::Error) (see error_on_reference)

regexp

regexp(coderef @code) (Venus::Check)

The regexp method configures the object to accept regular expression objects and returns the invocant.

Since 3.55

regexp example 1
# given: synopsis

package main;

$check = $check->regexp;

# bless(..., 'Venus::Check')

# my $result = $check->eval(qr//);

# true
regexp example 2
# given: synopsis

package main;

$check = $check->regexp;

# bless(..., 'Venus::Check')

# my $result = $check->eval('');

# false
regexp example 3
# given: synopsis

package main;

$check = $check->regexp;

# bless(..., 'Venus::Check')

# my $result = $check->result(qr//);

# qr//
regexp example 4
# given: synopsis

package main;

$check = $check->regexp;

# bless(..., 'Venus::Check')

# my $result = $check->result('');

# Exception! (isa Venus::Check::Error) (see error_on_coded)

result

result(any @args) (any)

The result method performs an "eval" operation and returns the value provided on success, and on failure raises an exception.

Since 3.55

result example 1
# given: synopsis

package main;

$check->string;

my $string = $check->result('hello');

# 'hello'
result example 2
# given: synopsis

package main;

$check->string;

my $string = $check->result(12345);

# Exception! (isa Venus::Check::Error) (see error_on_coded)
may raise Venus::Check::Error on.arrayref
# given: synopsis;

$check->tuple('string');

$check->result({});

# Error! (on.arrayref)
may raise Venus::Check::Error on.arrayref.count
# given: synopsis;

$check->tuple('string', 'string');

$check->result(['hello']);

# Error! (on.arrayref.count)
may raise Venus::Check::Error on.coded
# given: synopsis;

$check->string;

$check->result(12345);

# Error! (on.coded)
may raise Venus::Check::Error on.consumes
# given: synopsis;

package Example;

use Venus::Class;

package main;

$check->consumes('Venus::Role::Throwable');

$check->result(Example->new);

# Error! (on.consumes)
may raise Venus::Check::Error on.defined
# given: synopsis;

$check->string;

$check->result(undef);

# Error! (on.defined)
may raise Venus::Check::Error on.dirhandle
# given: synopsis;

$check->dirhandle;

$check->result('hello');

# Error! (on.dirhandle)
may raise Venus::Check::Error on.either
# given: synopsis;

$check->either('string', 'number');

$check->result([]);

# Error! (on.either)
may raise Venus::Check::Error on.enum
# given: synopsis;

$check->enum('this', 'that');

$check->result('other');

# Error! (on.enum)
may raise Venus::Check::Error on.filehandle
# given: synopsis;

$check->filehandle;

$check->result('hello');

# Error! (on.filehandle)
may raise Venus::Check::Error on.hashref
# given: synopsis;

$check->hashkeys('name', 'string');

$check->result([]);

# Error! (on.hashref)
may raise Venus::Check::Error on.hashref.empty
# given: synopsis;

$check->hashkeys('name', 'string');

$check->result({});

# Error! (on.hashref.empty)
may raise Venus::Check::Error on.includes
# given: synopsis;

$check->includes('string', 'number');

$check->result([]);

# Error! (on.includes)
may raise Venus::Check::Error on.identity
# given: synopsis;

$check->identity('Venus::String');

$check->result(Venus::Check->new);

# Error! (on.identity)
may raise Venus::Check::Error on.inherits
# given: synopsis;

$check->inherits('Venus::String');

$check->result(Venus::Check->new);

# Error! (on.inherits)
may raise Venus::Check::Error on.missing
# given: synopsis;

$check->attributes('name', 'string');

$check->result(bless{});

# Error! (on.missing)
may raise Venus::Check::Error on.package
# given: synopsis;

$check->package;

$check->result('not-a-package!');

# Error! (on.package)
may raise Venus::Check::Error on.package.loaded
# given: synopsis;

$check->package;

$check->result('Example::Fake');

# Error! (on.package.loaded)
may raise Venus::Check::Error on.pairs
# given: synopsis;

$check->hashkeys('name');

$check->result({name => 'example'});

# Error! (on.pairs)
may raise Venus::Check::Error on.reference
# given: synopsis;

$check->reference;

$check->result('hello');

# Error! (on.reference)
may raise Venus::Check::Error on.typeglob
# given: synopsis;

$check->glob;

$check->result('hello');

# Error! (on.typeglob)
may raise Venus::Check::Error on.value
# given: synopsis;

$check->value;

$check->result([]);

# Error! (on.value)
may raise Venus::Check::Error on.yesno
# given: synopsis;

$check->yesno;

$check->result('maybe');

# Error! (on.yesno)

routines

routines(string @names) (Venus::Check)

The routines method configures the object to accept an object having all of the routines provided, and returns the invocant.

Since 3.55

routines example 1
# given: synopsis

package main;

$check = $check->routines('result');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Check->new);

# true
routines example 2
# given: synopsis

package main;

use Venus::Config;

$check = $check->routines('result');

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Config->new);

# false
routines example 3
# given: synopsis

package main;

$check = $check->routines('result');

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Check->new);

# bless(..., 'Venus::Check')
routines example 4
# given: synopsis

package main;

use Venus::Config;

$check = $check->routines('result');

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_coded)
routines example 5
# given: synopsis

package main;

use Venus::Config;

$check = $check->routines('result');

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Config->new);

# Exception! (isa Venus::Check::Error) (see error_on_missing)

scalar

scalar(coderef @code) (Venus::Check)

The scalar method configures the object to accept scalar references and returns the invocant.

Since 3.55

scalar example 1
# given: synopsis

package main;

$check = $check->scalar;

# bless(..., 'Venus::Check')

# my $result = $check->eval(\'');

# true
scalar example 2
# given: synopsis

package main;

$check = $check->scalar;

# bless(..., 'Venus::Check')

# my $result = $check->eval('');

# false
scalar example 3
# given: synopsis

package main;

$check = $check->scalar;

# bless(..., 'Venus::Check')

# my $result = $check->result(\'');

# \''
scalar example 4
# given: synopsis

package main;

$check = $check->scalar;

# bless(..., 'Venus::Check')

# my $result = $check->result('');

# Exception! (isa Venus::Check::Error) (see error_on_coded)

scalarref

scalarref(coderef @code) (Venus::Check)

The scalarref method configures the object to accept scalar references and returns the invocant.

Since 3.55

scalarref example 1
# given: synopsis

package main;

$check = $check->scalarref;

# bless(..., 'Venus::Check')

# my $result = $check->eval(\'');

# true
scalarref example 2
# given: synopsis

package main;

$check = $check->scalarref;

# bless(..., 'Venus::Check')

# my $result = $check->eval('');

# false
scalarref example 3
# given: synopsis

package main;

$check = $check->scalarref;

# bless(..., 'Venus::Check')

# my $result = $check->result(\'');

# \''
scalarref example 4
# given: synopsis

package main;

$check = $check->scalarref;

# bless(..., 'Venus::Check')

# my $result = $check->result('');

# Exception! (isa Venus::Check::Error) (see error_on_coded)

string

string(coderef @code) (Venus::Check)

The string method configures the object to accept string values and returns the invocant.

Since 3.55

string example 1
# given: synopsis

package main;

$check = $check->string;

# bless(..., 'Venus::Check')

# my $result = $check->eval('hello');

# true
string example 2
# given: synopsis

package main;

$check = $check->string;

# bless(..., 'Venus::Check')

# my $result = $check->eval(12345);

# false
string example 3
# given: synopsis

package main;

$check = $check->string;

# bless(..., 'Venus::Check')

# my $result = $check->result('hello');

# 'hello'
string example 4
# given: synopsis

package main;

$check = $check->string;

# bless(..., 'Venus::Check')

# my $result = $check->result(12345);

# Exception! (isa Venus::Check::Error) (see error_on_coded)

tuple

tuple(string | within[arrayref, string] @args) (Venus::Check)

The tuple method configures the object to accept array references which conform to a tuple specification, and returns the invocant. The value being evaluated must contain at-least one element to match.

Since 3.55

tuple example 1
# given: synopsis

package main;

$check = $check->tuple('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->eval(['hello', 12345]);

# true
tuple example 2
# given: synopsis

package main;

$check = $check->tuple('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->eval([]);

# false
tuple example 3
# given: synopsis

package main;

$check = $check->tuple('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->result(['hello', 12345]);

# ['hello', 12345]
tuple example 4
# given: synopsis

package main;

$check = $check->tuple('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)
tuple example 5
# given: synopsis

package main;

$check = $check->tuple('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_arrayref)
tuple example 6
# given: synopsis

package main;

$check = $check->tuple('string', 'number');

# bless(..., 'Venus::Check')

# my $result = $check->result([]);

# Exception! (isa Venus::Check::Error) (see error_on_arrayref_count)

undef

undef(coderef @code) (Venus::Check)

The undef method configures the object to accept undefined values and returns the invocant.

Since 3.55

undef example 1
# given: synopsis

package main;

$check = $check->undef;

# bless(..., 'Venus::Check')

# my $result = $check->eval(undef);

# true
undef example 2
# given: synopsis

package main;

$check = $check->undef;

# bless(..., 'Venus::Check')

# my $result = $check->eval('');

# false
undef example 3
# given: synopsis

package main;

$check = $check->undef;

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# undef
undef example 4
# given: synopsis

package main;

$check = $check->undef;

# bless(..., 'Venus::Check')

# my $result = $check->result('');

# Exception! (isa Venus::Check::Error) (see error_on_coded)

value

value(coderef @code) (Venus::Check)

The value method configures the object to accept defined, non-reference, values, and returns the invocant.

Since 3.55

value example 1
# given: synopsis

package main;

$check = $check->value;

# bless(..., 'Venus::Check')

# my $result = $check->eval(1);

# true
value example 2
# given: synopsis

package main;

$check = $check->value;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# false
value example 3
# given: synopsis

package main;

$check = $check->value;

# bless(..., 'Venus::Check')

# my $result = $check->result(1);

# 1
value example 4
# given: synopsis

package main;

$check = $check->value;

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)
value example 5
# given: synopsis

package main;

$check = $check->value;

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_value)

what

what(any $data) (string)

The type method returns the canonical data type name for the value provided.

Since 3.55

what example 1
# given: synopsis

package main;

my $what = $check->what({});

# 'hashref'
what example 2
# given: synopsis

package main;

my $what = $check->what([]);

# 'arrayref'
what example 3
# given: synopsis

package main;

my $what = $check->what('Venus::Check');

# 'string'
what example 4
# given: synopsis

package main;

my $what = $check->what(Venus::Check->new);

# 'object'

within

within(string $type, string | within[arrayref, string] @args) (Venus::Check)

The within method configures the object, registering a constraint action as a sub-match operation, to accept array references, hash references, or mappable values (see Venus::Role::Mappable), and returns a new Venus::Check instance for the sub-match operation (not the invocant). This operation can traverse blessed array or hash based values, or objects derived from classes which consume the "mappable" role. The value being evaluated must contain at-least one element to match.

Since 3.55

within example 1
# given: synopsis

package main;

my $within = $check->within('arrayref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->eval(['hello']);

# true
within example 2
# given: synopsis

package main;

my $within = $check->within('arrayref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->eval([]);

# false
within example 3
# given: synopsis

package main;

my $within = $check->within('arrayref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result(['hello']);

# ['hello']
within example 4
# given: synopsis

package main;

my $within = $check->within('arrayref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)
within example 5
# given: synopsis

package main;

my $within = $check->within('arrayref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_arrayref)
within example 6
# given: synopsis

package main;

my $within = $check->within('arrayref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result([]);

# Exception! (isa Venus::Check::Error) (see error_on_arrayref_count)
within example 7
# given: synopsis

package main;

my $within = $check->within('arrayref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result([rand]);

# Exception! (isa Venus::Check::Error) (see error_on_coded)
within example 8
# given: synopsis

package main;

my $within = $check->within('hashref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->eval({title => 'hello'});

# true
within example 9
# given: synopsis

package main;

my $within = $check->within('hashref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->eval({});

# false
within example 10
# given: synopsis

package main;

my $within = $check->within('hashref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result({title => 'hello'});

# {title => 'hello'}
within example 11
# given: synopsis

package main;

my $within = $check->within('hashref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)
within example 12
# given: synopsis

package main;

my $within = $check->within('hashref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result([]);

# Exception! (isa Venus::Check::Error) (see error_on_hashref)
within example 13
# given: synopsis

package main;

my $within = $check->within('hashref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result({});

# Exception! (isa Venus::Check::Error) (see error_on_hashref_empty)
within example 14
# given: synopsis

package main;

my $within = $check->within('hashref', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result({title => rand});

# Exception! (isa Venus::Check::Error) (see error_on_coded)
within example 15
# given: synopsis

package main;

my $within = $check->within('Venus::Hash', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result({title => 'engineer'});

# Exception! (isa Venus::Check::Error) (see error_on_mappable_isa)
within example 16
# given: synopsis

package main;

use Venus::Hash;

my $within = $check->within('Venus::Hash', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->result(Venus::Hash->new);

# Exception! (isa Venus::Check::Error) (see error_on_mappable_empty)
within example 17
# given: synopsis

package main;

use Venus::Hash;

my $within = $check->within('Venus::Hash', 'string');

# bless(..., 'Venus::Check')

$check;

# bless(..., 'Venus::Check')

# my $result = $check->eval(Venus::Hash->new({title => 'engineer'}));

# true
may raise Venus::Check::Error on.within
# given: synopsis;

$check->within('scalarref', 'string');

# Error! (on.within)

yesno

yesno(coderef @code) (Venus::Check)

The yesno method configures the object to accept a string value, that's case insensitive, and that's either "y" or "yes" or 1 or "n" or "no" or 0, and returns the invocant.

Since 3.55

yesno example 1
# given: synopsis

package main;

$check = $check->yesno;

# bless(..., 'Venus::Check')

# my $result = $check->eval('yes');

# true
yesno example 2
# given: synopsis

package main;

$check = $check->yesno;

# bless(..., 'Venus::Check')

# my $result = $check->eval('yup');

# false
yesno example 3
# given: synopsis

package main;

$check = $check->yesno;

# bless(..., 'Venus::Check')

# my $result = $check->result('yes');

# 'yes'
yesno example 4
# given: synopsis

package main;

$check = $check->yesno;

# bless(..., 'Venus::Check')

# my $result = $check->result(undef);

# Exception! (isa Venus::Check::Error) (see error_on_defined)
yesno example 5
# given: synopsis

package main;

$check = $check->yesno;

# bless(..., 'Venus::Check')

# my $result = $check->result('yup');

# Exception! (isa Venus::Check::Error) (see error_on_yesno)

AUTHORS

Awncorp, awncorp@cpan.org

LICENSE

Copyright (C) 2022, Awncorp, awncorp@cpan.org.

This program is free software, you can redistribute it and/or modify it under the terms of the Apache license version 2.0.