Renamed DBIC::Positional as DBIC::Ordered.
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Validation.pm
index 623766c..4592a89 100644 (file)
@@ -4,10 +4,10 @@ use strict;
 use warnings;
 
 use base qw( DBIx::Class );
-use Carp qw( croak );
 use English qw( -no_match_vars );
 
-local $^W = 0; # Silence C:D:I redefined sub errors.
+#local $^W = 0; # Silence C:D:I redefined sub errors.
+# Switched to C::D::Accessor which doesn't do this. Hate hate hate hate.
 
 our $VERSION = '0.01';
 
@@ -20,8 +20,8 @@ sub validation_module {
     my $module = shift;
     
     eval("use $module");
-    croak("Unable to load the validation module '$module' because $EVAL_ERROR") if ($EVAL_ERROR);
-    croak("The '$module' module does not support the check method") if (!$module->can('check'));
+    $class->throw_exception("Unable to load the validation module '$module' because $EVAL_ERROR") if ($EVAL_ERROR);
+    $class->throw_exception("The '$module' module does not support the check method") if (!$module->can('check'));
     
     $class->_validation_module_accessor( $module );
 }
@@ -32,7 +32,7 @@ sub validation {
     
     $class->validation_module( $args{module} ) if (exists $args{module});
     $class->validation_profile( $args{profile} ) if (exists $args{profile});
-    $class->validatio_auto( $args{auto} ) if (exists $args{auto});
+    $class->validation_auto( $args{auto} ) if (exists $args{auto});
 }
 
 sub validate {
@@ -42,7 +42,7 @@ sub validate {
     my $profile = $self->validation_profile();
     my $result = $module->check( \%data => $profile );
     return $result if ($result->success());
-    croak( $result );
+    $self->throw_exception( $result );
 }
 
 sub insert {
@@ -95,14 +95,14 @@ And then somewhere else:
     auto => 1,
   );
 
-Calls validation_module(), validation_profile(), and validation_auto() if the corresponding 
+Calls validation_module(), validation_profile(), and validation_auto() if the corresponding
 argument is defined.
 
 =head2 validation_module
 
   __PACKAGE__->validation_module('Data::FormValidator');
 
-Sets the validation module to use.  Any module that supports a check() method just like 
+Sets the validation module to use.  Any module that supports a check() method just like
 Data::FormValidator's can be used here, such as FormValidator::Simple.
 
 Defaults to FormValidator::Simple.
@@ -119,24 +119,24 @@ Sets the profile that will be passed to the validation module.
 
   __PACKAGE__->validation_auto( 1 );
 
-This flag, when enabled, causes any updates or inserts of the class 
+This flag, when enabled, causes any updates or inserts of the class
 to call validate() before actually executing.
 
 =head2 validate
 
   $obj->validate();
 
-Validates all the data in the object against the pre-defined validation 
-module and profile.  If there is a problem then a hard error will be 
-thrown.  If you put the validation in an eval you can capture whatever 
+Validates all the data in the object against the pre-defined validation
+module and profile.  If there is a problem then a hard error will be
+thrown.  If you put the validation in an eval you can capture whatever
 the module's check() method returned.
 
 =head2 auto_validate
 
   __PACKAGE__->auto_validate( 0 );
 
-Turns on and off auto-validation.  This feature makes all UPDATEs and 
-INSERTs call the validate() method before doing anything.  The default 
+Turns on and off auto-validation.  This feature makes all UPDATEs and
+INSERTs call the validate() method before doing anything.  The default
 is for auto-validation to be on.
 
 Defaults to on.