diff options
author | emkael <emkael@tlen.pl> | 2020-05-05 14:25:42 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2020-05-05 14:25:42 +0200 |
commit | 62827e6cf470449c117624058fb36ad94804bcc0 (patch) | |
tree | 10cd1e4d36c34b694acfadaa69fc7f6ae2b1eabd /plugins/TimeMachine/Validator/SubTaskTimeTrackingValidator.php | |
parent | 7b66ddf2e4fbdb837e78d8b7dbaa9fc38391bc32 (diff) |
Diffstat (limited to 'plugins/TimeMachine/Validator/SubTaskTimeTrackingValidator.php')
-rw-r--r-- | plugins/TimeMachine/Validator/SubTaskTimeTrackingValidator.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/TimeMachine/Validator/SubTaskTimeTrackingValidator.php b/plugins/TimeMachine/Validator/SubTaskTimeTrackingValidator.php new file mode 100644 index 00000000..28421b66 --- /dev/null +++ b/plugins/TimeMachine/Validator/SubTaskTimeTrackingValidator.php @@ -0,0 +1,48 @@ +<?php + +namespace Kanboard\Plugin\TimeMachine\Validator; + +use Kanboard\Validator\BaseValidator; +use SimpleValidator\Validator; +use SimpleValidator\Validators; + +/** + * SubTask Time Tracking Validator + * + * @package Kanboard\Validator + * @author Frederic Guillot + */ +class SubTaskTimeTrackingValidator extends BaseValidator +{ + + /** + * Validate SubTackTimeTracking from form + * + * @param array $values Form values + * + * @return array $valid, $errors [0] = Success or not, [1] = List of errors + */ + public function validates(array $values) + { + $valids = []; + $errors = []; + + foreach ($values as $key => $value) { + $rules = array( + new Validators\Required('id', t('The task time tracking id is required')), + new Validators\Date('start', t('Invalid date'), $this->dateParser->getParserFormats()), + new Validators\Date('end', t('Invalid date'), $this->dateParser->getParserFormats()), + ); + + $v = new Validator($value, $rules); + + $valids[$key] = $v->execute(); + $errors[$key] = $v->getErrors(); + } + + return array( + $valids, + $errors + ); + } +} |