package GO::Data_FormValidator; use strict; use lib '/Users/gwg/go/scratch/tools'; use base 'Data::FormValidator'; use GO::Data_FormValidator_Results; use Data::Dumper; sub check { my ( $self, $data, $name ) = @_; # check can be used as a class method for simple cases if (not ref $self) { my $class = $self; $self = {}; bless $self, $class; } my $profile; if ( ref $name ) { $profile = $name; } else { $self->load_profiles; $profile = $self->{profiles}{$name}; die "No such profile $name. Dying " unless $profile; } die "input profile must be a hash ref. Dying " unless ref $profile eq "HASH"; # add in defaults from new(), if any if ($self->{defaults}) { $profile = { %{$self->{defaults}}, %$profile }; } # check the profile syntax or die with an error. Data::FormValidator::_check_profile_syntax($profile); my $results = GO::Data_FormValidator_Results->new( $profile, $data ); # As a special case, pass through any defaults for the 'msgs' key. $results->msgs($self->{defaults}->{msgs}) if $self->{defaults}->{msgs}; return $results; } 1;