Skip to content

Commit

Permalink
Merge pull request #5 from msmakouz/feature/default-validator
Browse files Browse the repository at this point in the history
Adding default validator
  • Loading branch information
butschster authored Sep 29, 2022
2 parents 363943a + 5111c84 commit cec2797
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
],
"require": {
"php": "^8.1",
"spiral/filters": "^3.0",
"spiral/validation": "^3.0",
"spiral/boot": "^3.0",
"spiral/filters": "^3.1",
"spiral/validation": "^3.1",
"spiral/boot": "^3.1",
"illuminate/validation": "^8.0|^9.0",
"symfony/psr-http-message-bridge": "^2.0",
"spiral/console": "^3.0"
"spiral/console": "^3.1"
},
"require-dev": {
"mockery/mockery": "^1.5",
"spiral/framework": "^3.0",
"spiral/framework": "^3.1",
"spiral/nyholm-bridge": "^1.2",
"spiral/attributes": "^2.8 || ^3.0",
"spiral/attributes": "^2.8 || ^3.1",
"phpunit/phpunit": "^9.5",
"spiral/testing": "^2.0",
"vimeo/psalm": "^4.9"
Expand Down
3 changes: 2 additions & 1 deletion src/Bootloader/ValidatorBootloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ public function init(HttpBootloader $http): void
]);
}

public function boot(ValidationProvider $provider): void
public function boot(ValidationProvider $provider, ValidationBootloader $validation): void
{
$provider->register(
FilterDefinition::class,
static fn(LaravelValidation $validation) => $validation
);
$validation->setDefaultValidator(FilterDefinition::class);
}

private function initValidation(TranslatorInterface $translator): ValidationInterface
Expand Down
2 changes: 2 additions & 0 deletions tests/src/Functional/Bootloader/ValidatorBootloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Spiral\Validation\Laravel\Bootloader\ValidatorBootloader;
use Spiral\Validation\Laravel\FilterDefinition;
use Spiral\Validation\Laravel\LaravelValidation;
use Spiral\Validation\ValidationInterface;
use Spiral\Validation\ValidationProviderInterface;

final class ValidatorBootloaderTest extends TestCase
Expand All @@ -22,5 +23,6 @@ public function testValidationRegistered(): void
$provider = $this->getContainer()->get(ValidationProviderInterface::class);

$this->assertInstanceOf(LaravelValidation::class, $provider->getValidation(FilterDefinition::class));
$this->assertContainerBoundAsSingleton(ValidationInterface::class, LaravelValidation::class);
}
}

0 comments on commit cec2797

Please sign in to comment.