The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

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::Type 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)

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

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)

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)

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)

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)

type

  type(any $data) (string)

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

Since 3.55

type example 1
  # given: synopsis

  package main;

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

  # 'hashref'
type example 2
  # given: synopsis

  package main;

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

  # 'arrayref'
type example 3
  # given: synopsis

  package main;

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

  # 'string'
type example 4
  # given: synopsis

  package main;

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

  # 'object'

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)

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 or hash based values, 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. 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)

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)

ERRORS

This package may raise the following errors:

error: error_on_arrayref

This package may raise an error_on_arrayref exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_arrayref',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_arrayref"

  # my $message = $error->render;

  # "Failed checking test, value provided is not an arrayref or arrayref derived, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_arrayref_count

This package may raise an error_on_arrayref_count exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_arrayref_count',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_arrayref_count"

  # my $message = $error->render;

  # "Failed checking test, incorrect item count in arrayref or arrayref derived object, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_coded

This package may raise an error_on_coded exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    expected => 'string',
    received => 'number',
    throw => 'error_on_coded',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_coded"

  # my $message = $error->render;

  # "Failed checking test, expected string, received number, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

  # my $expected = $error->stash('expected');

  # "string"

  # my $received = $error->stash('received');

  # "number"
error: error_on_consumes

This package may raise an error_on_consumes exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    role => 'Example::Role',
    throw => 'error_on_consumes',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_consumes"

  # my $message = $error->render;

  # "Failed checking test, object does not consume the role \"Example::Role\", at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

  # my $role = $error->stash('role');

  # "Example::Role"
error: error_on_defined

This package may raise an error_on_defined exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_defined',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_defined"

  # my $message = $error->render;

  # "Failed checking test, value provided is undefined, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_either

This package may raise an error_on_either exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    errors => [
      'Failed condition 1',
      'Failed condition 2',
    ],
    throw => 'error_on_either',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_either"

  # my $message = $error->render;

  # "Failed checking either-or condition:\n\nFailed condition 1\n\nFailed condition 2"

  # my $errors = $error->stash('errors');

  # ['Failed condition 1', Failed condition 2']

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_enum

This package may raise an error_on_enum exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    data => 'black',
    enum => ['this', 'that'],
    throw => 'error_on_enum',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_enum"

  # my $message = $error->render;

  # "Failed checking test, received black, valid options are this, that, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

  # my $data = $error->stash('data');

  # "black"

  # my $enum = $error->stash('enum');

  # ['this', 'that']
error: error_on_hashref

This package may raise an error_on_hashref exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_hashref',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_hashref"

  # my $message = $error->render;

  # "Failed checking test, value provided is not a hashref or hashref derived, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_hashref_empty

This package may raise an error_on_hashref_empty exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_hashref_empty',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_hashref_empty"

  # my $message = $error->render;

  # "Failed checking test, no items found in hashref or hashref derived object, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_identity

This package may raise an error_on_identity exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    name => 'Example',
    throw => 'error_on_identity',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_identity"

  # my $message = $error->render;

  # "Failed checking test, object is not a Example or derived object, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

  # my $name = $error->stash('name');

  # "Example"
error: error_on_includes

This package may raise an error_on_includes exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    errors => [
      'Failed condition 1',
      'Failed condition 2',
    ],
    throw => 'error_on_includes',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_includes"

  # my $message = $error->render;

  # "Failed checking union-includes condition:\n\nFailed condition 1\n\nFailed condition 2"

  # my $errors = $error->stash('errors');

  # ['Failed condition 1', Failed condition 2']

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_inherits

This package may raise an error_on_inherits exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    name => 'Example',
    throw => 'error_on_inherits',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_inherits"

  # my $message = $error->render;

  # "Failed checking test, object is not a Example derived object, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

  # my $name = $error->stash('name');

  # "Example"
error: error_on_missing

This package may raise an error_on_missing exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    name => 'execute',
    throw => 'error_on_missing',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_missing"

  # my $message = $error->render;

  # "Failed checking test, "execute" is missing, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

  # my $name = $error->stash('name');

  # "execute"
error: error_on_package

This package may raise an error_on_package exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    data => 'main',
    from => 'test',
    throw => 'error_on_package',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_package"

  # my $message = $error->render;

  # "Failed checking test, \"main\" is not a valid package name, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

  # my $data = $error->stash('data');

  # "main"
error: error_on_package_loaded

This package may raise an error_on_package_loaded exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    data => 'main',
    from => 'test',
    throw => 'error_on_package_loaded',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_package_loaded"

  # my $message = $error->render;

  # "Failed checking test, \"main\" is not loaded, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

  # my $data = $error->stash('data');

  # "main"
error: error_on_pairs

This package may raise an error_on_pairs exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_pairs',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_pairs"

  # my $message = $error->render;

  # "Failed checking test, imblanced key/value pairs provided, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_reference

This package may raise an error_on_reference exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_reference',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_reference"

  # my $message = $error->render;

  # "Failed checking test, value provided is not a reference, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_unknown

This package may raise an error_on_unknown exception.

example 1

  # given: synopsis;

  my $input = {
    throw => 'error_on_unknown',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_unknown"

  # my $message = $error->render;

  # "Failed performing check for unknown reason"

  # my $from = $error->stash('from');

  # undef

  # my $at = $error->stash('at');

  # "."
error: error_on_value

This package may raise an error_on_value exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_value',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_value"

  # my $message = $error->render;

  # "Failed checking test, value provided is a reference, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_within

This package may raise an error_on_within exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    type => 'scalarref',
    throw => 'error_on_within',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_within"

  # my $message = $error->render;

  # "Invalid type \"scalarref\" provided to the \"within\" method"

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."
error: error_on_yesno

This package may raise an error_on_yesno exception.

example 1

  # given: synopsis;

  my $input = {
    at => '.',
    from => 'test',
    throw => 'error_on_yesno',
  };

  my $error = $check->catch('error', $input);

  # my $name = $error->name;

  # "on_yesno"

  # my $message = $error->render;

  # "Failed checking test, value provided is not a recognized \"yes\" or \"no\" value, at ."

  # my $from = $error->stash('from');

  # "test"

  # my $at = $error->stash('at');

  # "."

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.