logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

DBIx::Class::Helper::Schema::Verifier - Verify the Results and ResultSets of your Schemata

Author

       Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>

Description

       "DBIx::Class::Helper::Schema::Verifier" is a minuscule framework to assist in creating schemata that are
       to your very own exacting specifications.  It is inspired by my own travails in discovering that "use mro
       'c3'" is both required and barely documented in much Perl code.  As time goes by I expect to add many
       more verifiers, but with this inaugural release I am merely including
       DBIx::Class::Helper::Schema::Verifier::C3.

Interface Methods

result_verifiers
       You must implement "result_verifiers" in your subclass of "::Verifier".  Each verifier gets called on the
       schema and gets each result and resultset together as arguments.  You can use this to validate almost
       anything about the results and resultsets of a schema; contributions are warmly welcomed.

More Errors

       Initially I kept this module simple, but after using it in production at ZipRecruiter
       <https://www.ziprecruiter.com> I found that showing the user the first error that occurred and then
       giving up was pretty annoying.  Now "Schema::Verifier" wraps both "load_namespaces" in
       DBIx::Class::Schema and "load_classes" in DBIx::Class::Schema and shows all the exceptions encoutered as
       a list at the end of loading all the results.

Name

       DBIx::Class::Helper::Schema::Verifier - Verify the Results and ResultSets of your Schemata

Synopsis

        package MyApp::Schema;

        __PACKAGE__->load_components('Helper::Schema::Verifier');

        sub result_verifiers {
          (
             sub {
                my ($self, $result, $set) = @_;

                for ($result, $set) {
                   die "$_ does not start with the letter A" unless m/^A/
                }
             },
             shift->next::method,
          )
        }

See Also