• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nepada / file-upload-control / 3609782379

pending completion
3609782379

push

github

Petr Morávek
v1.4.0

637 of 706 relevant lines covered (90.23%)

0.9 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

83.33
/src/FileUploadControl/Validation/UploadValidation.php
1
<?php
2
declare(strict_types = 1);
3

4
namespace Nepada\FileUploadControl\Validation;
5

6
use Nepada\FileUploadControl\FileUploadControl;
7
use Nette\Forms\Control;
8
use Nette\Forms\Rules;
9
use Nette\Utils\Html;
10

11
/**
12
 * @internal
13
 */
14
trait UploadValidation
15
{
16

17
    protected FakeUploadControl $fakeUploadControl;
18

19
    private Rules $rules;
20

21
    /**
22
     * @param callable|string $validator
23
     * @param string|Html $errorMessage
24
     * @param mixed $arg
25
     * @return static
26
     */
27
    public function addRule($validator, $errorMessage = null, $arg = null): self
28
    {
29
        $this->rules->addRule($validator, $errorMessage, $arg);
1✔
30
        return $this;
1✔
31
    }
32

33
    /**
34
     * @param callable|string $validator
35
     * @param mixed $value
36
     * @return Rules
37
     */
38
    public function addCondition($validator, $value = null): Rules
39
    {
40
        return $this->rules->addCondition($validator, $value);
×
41
    }
42

43
    /**
44
     * @param Control $control
45
     * @param callable|string $validator
46
     * @param mixed $value
47
     * @return Rules
48
     */
49
    public function addConditionOn(Control $control, $validator, $value = null): Rules
50
    {
51
        return $this->rules->addConditionOn($control, $validator, $value);
×
52
    }
53

54
    public function getRules(): Rules
55
    {
56
        return $this->rules;
1✔
57
    }
58

59
    /**
60
     * @param bool|string|Html $value
61
     * @return static
62
     */
63
    public function setRequired($value = true): self
1✔
64
    {
65
        $this->rules->setRequired($value);
1✔
66
        return $this;
1✔
67
    }
68

69
    public function isRequired(): bool
70
    {
71
        return $this->rules->isRequired();
1✔
72
    }
73

74
    public function validate(): void
75
    {
76
        if ($this->isDisabled()) {
1✔
77
            return;
×
78
        }
79
        $this->cleanErrors();
1✔
80
        $this->rules->validate();
1✔
81
    }
1✔
82

83
    private function initializeValidation(FileUploadControl $control): void
1✔
84
    {
85
        $this->fakeUploadControl = new FakeUploadControl($control);
1✔
86
        $this->rules = new Rules($this->fakeUploadControl);
1✔
87
    }
1✔
88

89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc