From 6d79290353692e1f1947edb1f3092ecd02000acc Mon Sep 17 00:00:00 2001 From: einhverfr Date: Tue, 6 Nov 2007 23:45:06 +0000 Subject: Adding support for validation logic in DBObject modules git-svn-id: https://ledger-smb.svn.sourceforge.net/svnroot/ledger-smb/trunk@1856 4979c152-3d1c-0410-bac9-87ea11338e46 --- LedgerSMB/DBObject.pm | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/LedgerSMB/DBObject.pm b/LedgerSMB/DBObject.pm index 4c96c82e..3451d823 100644 --- a/LedgerSMB/DBObject.pm +++ b/LedgerSMB/DBObject.pm @@ -26,6 +26,9 @@ this way as is any information that is needed. Provides the basic mapping of parameters to the SQL stored procedure function arguments. +=item __validate__ is called on every new() invocation. It is blank in this +module but can be overridden in decendant modules. + =back =head1 Copyright (C) 2007, The LedgerSMB core team. @@ -54,6 +57,8 @@ sub AUTOLOAD { sub DESTROY {} +sub __validate__ {} + sub new { my $class = shift @_; my %args = (ref($_[0]) eq 'HASH')? %{$_[0]}: @_; @@ -83,7 +88,8 @@ sub new { else { $self->merge($base); } - $self; + $self->__validate__(); + return $self; } sub set_ordering { -- cgit v1.2.3