Adds new validation method for rendered newsletter body
This commit is contained in:
@ -10,7 +10,8 @@ class ModelValidator extends \Sudzy\Engine {
|
||||
function __construct() {
|
||||
parent::__construct();
|
||||
$this->validators = array(
|
||||
'validEmail' => 'validateEmail'
|
||||
'validEmail' => 'validateEmail',
|
||||
'validRenderedNewsletterBody' => 'validateRenderedNewsletterBody'
|
||||
);
|
||||
$this->setupValidators();
|
||||
}
|
||||
@ -27,4 +28,11 @@ class ModelValidator extends \Sudzy\Engine {
|
||||
function validateEmail($email) {
|
||||
return is_email($email) !== false;
|
||||
}
|
||||
}
|
||||
|
||||
function validateRenderedNewsletterBody($newsletter_body) {
|
||||
$newsletter_body = (!is_serialized($newsletter_body)) ?
|
||||
$newsletter_body :
|
||||
unserialize($newsletter_body);
|
||||
return (is_null($newsletter_body) || (is_array($newsletter_body) && !empty($newsletter_body['html']) && !empty($newsletter_body['text'])));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user