Skip to content

Commit

Permalink
Rename RelativeRuleData
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenvanassche committed Dec 21, 2022
1 parent 249aff3 commit c938580
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Spatie\LaravelData\Contracts;

interface RelativeRuleData
interface RelativeRuleGenerationData
{

}
4 changes: 2 additions & 2 deletions src/Support/DataClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
use Spatie\LaravelData\Contracts\AppendableData;
use Spatie\LaravelData\Contracts\DataObject;
use Spatie\LaravelData\Contracts\IncludeableData;
use Spatie\LaravelData\Contracts\RelativeRuleData;
use Spatie\LaravelData\Contracts\RelativeRuleGenerationData;
use Spatie\LaravelData\Contracts\ResponsableData;
use Spatie\LaravelData\Contracts\TransformableData;
use Spatie\LaravelData\Contracts\ValidateableData;
Expand Down Expand Up @@ -71,7 +71,7 @@ public static function create(ReflectionClass $class): self
validateable: $class->implementsInterface(ValidateableData::class),
wrappable: $class->implementsInterface(WrappableData::class),
attributes: $attributes,
relativeRuleGeneration: $class->implementsInterface(RelativeRuleData::class),
relativeRuleGeneration: $class->implementsInterface(RelativeRuleGenerationData::class),
);
}

Expand Down
14 changes: 7 additions & 7 deletions tests/ValidationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use Spatie\LaravelData\Attributes\Validation\Min;
use Spatie\LaravelData\Attributes\Validation\Required;
use Spatie\LaravelData\Attributes\WithoutValidation;
use Spatie\LaravelData\Contracts\RelativeRuleData;
use Spatie\LaravelData\Contracts\RelativeRuleGenerationData;
use Spatie\LaravelData\Data;
use Spatie\LaravelData\DataCollection;
use Spatie\LaravelData\Exceptions\CannotBuildRelativeRules;
Expand Down Expand Up @@ -373,7 +373,7 @@ class NestedClassD extends Data {
});

it('can use nested payloads in nested data', function () {
class NestedClassF extends Data implements RelativeRuleData
class NestedClassF extends Data implements RelativeRuleGenerationData
{
public bool $strict;

Expand Down Expand Up @@ -599,7 +599,7 @@ class CollectionClassA extends Data {

it('can nest data in collections using relative rule generation', function () {

class NestedClassH extends Data implements RelativeRuleData
class NestedClassH extends Data implements RelativeRuleGenerationData
{
public string $string;

Expand Down Expand Up @@ -643,7 +643,7 @@ public static function rules(array $payload, ?string $path): array
})->throwsIf(fn() => CannotBuildRelativeRules::shouldThrow(), CannotBuildRelativeRules::class);

it('can nest data in classes inside collections using relative rule generation', function () {
class NestedClassJ extends Data implements RelativeRuleData {
class NestedClassJ extends Data implements RelativeRuleGenerationData {
public string $string;
#[Required]
public bool $isEmail;
Expand Down Expand Up @@ -697,7 +697,7 @@ class CollectionClassK extends Data {
})->throwsIf(fn() => CannotBuildRelativeRules::shouldThrow(), CannotBuildRelativeRules::class);

it('can nest data in deep collections using relative rule generation', function () {
class NestedClassL extends Data implements RelativeRuleData {
class NestedClassL extends Data implements RelativeRuleGenerationData {
public string $deepString;
#[Required]
public bool $deepIsEmail;
Expand All @@ -710,7 +710,7 @@ public static function rules(array $payload, ?string $path): array
}
}

class NestedClassM extends Data implements RelativeRuleData {
class NestedClassM extends Data implements RelativeRuleGenerationData {
public string $string;
#[Required]
public bool $isEmail;
Expand Down Expand Up @@ -820,7 +820,7 @@ public static function rules(array $payload , ?string $path): array
it('can nest data using relative rule generation', function () {
eval(<<<'PHP'
use Spatie\LaravelData\Data;
class NestedClassI extends Data implements \Spatie\LaravelData\Contracts\RelativeRuleData {
class NestedClassI extends Data implements \Spatie\LaravelData\Contracts\RelativeRuleGenerationData {
public string $string;
#[\Spatie\LaravelData\Attributes\Validation\Required]
public bool $isEmail;
Expand Down

0 comments on commit c938580

Please sign in to comment.