TaskValidator.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace App\Repositories\Validators\Dianli;
  3. use \Prettus\Validator\Contracts\ValidatorInterface;
  4. use \Prettus\Validator\LaravelValidator;
  5. /**
  6. * Class TaskValidator.
  7. *
  8. * @package namespace App\Repositories\Validators\Dianli;
  9. */
  10. class TaskValidator extends LaravelValidator
  11. {
  12. /**
  13. * Validation Rules
  14. *
  15. * @var array
  16. */
  17. protected $rules = [
  18. ValidatorInterface::RULE_CREATE => [
  19. 'name' => 'required',
  20. 'type' => 'required|in:1,2',
  21. 'start_date' => 'required|date',
  22. 'end_date' => 'sometimes|nullable|date',
  23. 'weeks' => 'sometimes|nullable|array',
  24. 'paper_id' => 'sometimes|nullable|integer',
  25. 'assign_admin_ids' => 'required|array',
  26. 'status' => 'sometimes|nullable|integer',
  27. ],
  28. ValidatorInterface::RULE_UPDATE => [
  29. 'name' => 'required',
  30. 'type' => 'required|in:1,2',
  31. 'start_date' => 'sometimes|nullable|date',
  32. 'end_date' => 'sometimes|nullable|date',
  33. 'weeks' => 'sometimes|nullable|array',
  34. 'paper_id' => 'sometimes|nullable|integer',
  35. 'assign_admin_ids' => 'required|array',
  36. 'status' => 'sometimes|nullable|integer',
  37. ],
  38. ];
  39. }