Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kentnl/moosex-attribute-validatewithexception
Cause validation failures to throw exception objects.
https://github.com/kentnl/moosex-attribute-validatewithexception
Last synced: 4 days ago
JSON representation
Cause validation failures to throw exception objects.
- Host: GitHub
- URL: https://github.com/kentnl/moosex-attribute-validatewithexception
- Owner: kentnl
- License: other
- Created: 2011-06-17T21:59:07.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2017-03-12T02:46:08.000Z (over 7 years ago)
- Last Synced: 2023-08-20T22:00:28.181Z (about 1 year ago)
- Language: Perl
- Homepage:
- Size: 275 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkdn
- Changelog: Changes
- License: LICENSE
Awesome Lists containing this project
README
# NAME
MooseX::Attribute::ValidateWithException - Cause validation failures to throw exception objects.
# VERSION
version v0.4.1
# SYNOPSIS
{
package Foo;
use Moose;
use MooseX::Attribute::ValidateWithException;has foo => (
isa => 'Str',
is => 'rw',
required => 1,
);
__PACKAGE__->meta->make_immutable;
no Moose;
}use Try::Tiny;
try {
Foo->new( foo => { this_is => [qw( not what we were wanting )] } );
} catch {
say $_->name if blessed( $_ ) && $_->isa('Thingy');
};# DESCRIPTION
**ALPHA QUALITY SOFTWARE**.
At present, when an attribute fails validation, Moose internally die()'s with a
string. There is also no way to throw an exception object as part of the
validation message, ( in order to give more context on the problem ), without
also breaking how much of the validation works.This module is an experiment in providing that feature, which really should be
done in Moose itself, and done better, which is why it has been given such an
obtuse name.This module makes no promises of forwards compatibility with a future Moose
release, in order to permit Moose to do whatever they want and not worry about
"breaking code" that uses this module. ( So that they can easily replace this
module in incompatible ways )**If your code breaking is unacceptable, do _not_ use this module**.
Use of this module assumes several things.
- 1. You are o.k. with your code breaking in a future Moose release.
- 2. You are o.k. with re-writing any and all code that depends on this
functionality, if a future Moose release is incompatible with this module.I'm not saying I won't do my best to provide forwards compatibility, but it is
highly unlikely it will be possible, due to differences in package naming
which may be essential for handling exceptions.# AUTHOR
Kent Fredric
# COPYRIGHT AND LICENSE
This software is copyright (c) 2017 by Kent Fredric .
This is free software; you can redistribute it and/or modify it under
the same terms as the Perl 5 programming language system itself.