From cd3cf233770722ecb8a1ec9e36f1dea2542d3309 Mon Sep 17 00:00:00 2001 From: Peter Rotich <peter@osticket.com> Date: Fri, 31 Jan 2014 19:18:05 +0000 Subject: [PATCH] Add support for * input type to Validator This is required when validating a message which could be a string or an object. --- include/class.ticket.php | 2 +- include/class.validator.php | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/include/class.ticket.php b/include/class.ticket.php index fb6e5065b..de0befdff 100644 --- a/include/class.ticket.php +++ b/include/class.ticket.php @@ -2172,7 +2172,7 @@ class Ticket { $id=0; $fields=array(); - $fields['message'] = array('type'=>'text', 'required'=>1, 'error'=>'Message required'); + $fields['message'] = array('type'=>'*', 'required'=>1, 'error'=>'Message required'); switch (strtolower($origin)) { case 'web': $fields['topicId'] = array('type'=>'int', 'required'=>1, 'error'=>'Select help topic'); diff --git a/include/class.validator.php b/include/class.validator.php index f01bcb38c..c41058e05 100644 --- a/include/class.validator.php +++ b/include/class.validator.php @@ -61,6 +61,10 @@ class Validator { $this->errors[$k]=$field['error']; continue; } + + //We don't care about the type. + if ($field['type'] == '*') continue; + //Do the actual validation based on the type. switch(strtolower($field['type'])): case 'integer': @@ -73,7 +77,7 @@ class Validator { case 'double': if(!is_numeric($this->input[$k])) $this->errors[$k]=$field['error']; - break; + break; case 'text': case 'string': if(!is_string($this->input[$k])) @@ -84,9 +88,9 @@ class Validator { $this->errors[$k]=$field['error']; break; case 'radio': - if(!isset($this->input[$k])) - $this->errors[$k]=$field['error']; - break; + if(!isset($this->input[$k])) + $this->errors[$k]=$field['error']; + break; case 'date': //TODO...make sure it is really in GNU date format.. if(strtotime($this->input[$k])===false) $this->errors[$k]=$field['error']; -- GitLab