Skip to content

Commit 01576ce

Browse files
Added validator hints
1 parent 1a5f573 commit 01576ce

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/Command.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
class Command
1111
{
12-
protected static $version = '1.0.4';
12+
protected static $version = '1.0.5';
1313

1414
protected array $options = [];
1515

@@ -104,6 +104,7 @@ protected function collect(): static
104104
$this->climate()->line('<light_green>✓</light_green> added custom methods');
105105
$types->withFieldMethods();
106106
$types->withTraitMethods();
107+
$types->withValidators();
107108
}
108109

109110
if ($this->include('decorators')) {

src/Types.php

+12
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use Kirby\Cms\HasMethods;
1313
use Kirby\Filesystem\F;
1414
use Kirby\Toolkit\A;
15+
use Kirby\Toolkit\V;
1516
use LukasKleinschmidt\Types\Methods\BlueprintMethod;
1617
use LukasKleinschmidt\Types\Methods\FieldMethod;
1718
use ReflectionClass;
@@ -264,6 +265,17 @@ public function withTraitMethods(): void
264265
}
265266
}
266267

268+
public function withValidators(): void
269+
{
270+
$target = new ReflectionClass(V::class);
271+
272+
foreach (V::$validators as $name => $closure) {
273+
$function = new ReflectionFunction($closure);
274+
275+
$this->pushMethod(new Method($function, $target, $name));
276+
}
277+
}
278+
267279
public function addAliases(array $aliases): void
268280
{
269281
foreach ($aliases as $name => $class) {

0 commit comments

Comments
 (0)