X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2FRecord.pm;h=b24b69e82cbacccd7e5e2a6cccbe16230234ff2b;hb=078dc41cbf3edc2fa0a61b9c307921b0aaaf3cbe;hp=9eb1c9aebfad64599dbfb983068a03e4100c6b5b;hpb=ae40f1d7aa1a0fcf8c32c60660a51de3551854d8;p=freeside.git diff --git a/FS/FS/Record.pm b/FS/FS/Record.pm index 9eb1c9aeb..b24b69e82 100644 --- a/FS/FS/Record.pm +++ b/FS/FS/Record.pm @@ -25,6 +25,7 @@ use FS::Schema qw(dbdef); use FS::SearchCache; use FS::Msgcat qw(gettext); #use FS::Conf; #dependency loop bs, in install_callback below instead +use Email::Valid; use FS::part_virtual_field; @@ -3364,6 +3365,36 @@ sub ut_agentnum_acl { } + +=item ut_email COLUMN + +Check column contains a valid E-Mail address + +=cut + +sub ut_email { + my ( $self, $field ) = @_; + Email::Valid->address( $self->getfield( $field ) ) + ? '' + : "Illegal (email) field $field: ". $self->getfield( $field ); +} + +=item ut_emailn COLUMN + +Check column contains a valid E-Mail address + +May be null + +=cut + +sub ut_emailn { + my ( $self, $field ) = @_; + + $self->getfield( $field ) =~ /^$/ + ? $self->getfield( $field, '' ) + : $self->ut_email( $field ); +} + =item trim_whitespace FIELD[, FIELD ... ] Strip leading and trailing spaces from the value in the named FIELD(s).