NAME

Brick::General - constraints for domain-nonspecific stuff

SYNOPSIS

use Brick;

DESCRIPTION

Single fields

_is_blank( HASHREF )
_is_true( HASHREF )
_is_defined( HASHREF )

Multiple field conditions

defined_fields( HASHREF )

A wrapper around __fields_are_something to supply the code reference to verify that each field for definedness. It takes the same input.

true_fields( HASHREF )

A wrapper around __fields_are_something to supply the code reference to verify that each field for true values. It takes the same input.

false_fields( HASHREF )

A wrapper around __fields_are_something to supply the code reference to verify that each field for false values. It takes the same input.

blank_fields( HASHREF )

A wrapper around __fields_are_something to supply the code reference to verify that each field has blank values. It takes the same input.

exist_fields( HASHREF )

A wrapper around __fields_are_something to supply the code reference to verify that each field has blank values. It takes the same input.

allowed_fields( HASHREF )

A wrapper around _remove_extra_fields to remove anything not in the list of the key 'allowed_fields' in HASHREF.

This constraint only cares about fields that do not belong in the input. It does not, for instance, ensure that all the fields that should be there are. Use required fields for that.

required_fields( HASHREF )

A wrapper around _fields_are_defined_and_not_null_string to check for the presence of the required fields. A required field must exist in the input hash and have a defined value that is not the null string.

_fields_exist( HASHREF )
fields  - an anonymous array of fields that must exist in input

If all of the fields satisfy the condition, it does not die. If some of the fields do not satisfy the condition, it dies with a hash reference whose keys are:

message - message about the error
errors  - anonymous array of fields that failed the condition
handler - anonymous array of fields that satisfy the condition

If a code error occurs, it dies with a simple scalar.

__fields_are_something( HASHREF, CODEREF )

Applies CODEREF to all of the fields in HASHREF->{fields}.

fields      - an anonymous array of fields to apply CODEREF to
description - a textual description of the test (has default)
test_name   - short (couple word) description of test (e.g. "defined")

If all of the fields satisfy the condition, it does not die. If some of the fields do not satisfy the condition, it dies with a hash reference whose keys are:

message - message about the error
errors  - anonymous array of fields that failed the condition
handler - anonymous array of fields that satisfy the condition

If a code error occurs, it dies with a simple scalar.

_fields_are_defined_and_not_null_string( HASHREF )

Check that all fields in HASHREF->{fields) are defined and have a true value. See __fields_are_something for details.

_fields_are_defined( HASHREF )

Check that all fields in HASHREF->{fields) are defined. See __fields_are_something for details.

_fields_are_blank( HASHREF )

Check that all fields in HASHREF->{fields) are blank (either undefined or the empty string). See __fields_are_something for details.

_fields_are_false( HASHREF )

Check that all fields in HASHREF->{fields) are false (in the Perl sense). See __fields_are_something for details.

_fields_are_true( HASHREF )

Check that all fields in HASHREF->{fields) are true (in the Perl sense). See __fields_are_something for details.

TO DO

TBA

SEE ALSO

TBA

SOURCE AVAILABILITY

This source is in Github:

https://github.com/briandfoy/brick

AUTHOR

brian d foy, <bdfoy@cpan.org>

COPYRIGHT

Copyright © 2007-2022, brian d foy <bdfoy@cpan.org>. All rights reserved.

You may redistribute this under the terms of the Artistic License 2.0.