null
Find a file
Brian Faust 680ff3b946
wip
Signed-off-by: Brian Faust <brian@cline.sh>
2025-12-11 15:11:01 +02:00
.github wip 2025-12-11 15:11:01 +02:00
cookbook first commit 2025-10-19 09:18:42 +03:00
docker/php wip 2025-12-11 15:11:01 +02:00
src wip 2025-12-11 15:11:01 +02:00
tests wip 2025-12-11 15:11:01 +02:00
.editorconfig first commit 2025-10-19 09:18:42 +03:00
.gitattributes first commit 2025-10-19 09:18:42 +03:00
.gitignore first commit 2025-10-19 09:18:42 +03:00
CHANGELOG.md first commit 2025-10-19 09:18:42 +03:00
CODE_OF_CONDUCT.md first commit 2025-10-19 09:18:42 +03:00
composer.json wip 2025-12-11 15:11:01 +02:00
CONTRIBUTING.md first commit 2025-10-19 09:18:42 +03:00
docker-compose.yml wip 2025-12-11 15:11:01 +02:00
ecs.php wip 2025-12-11 15:11:01 +02:00
LICENSE.md first commit 2025-10-19 09:18:42 +03:00
Makefile wip 2025-12-11 15:11:01 +02:00
phpstan-baseline.neon first commit 2025-10-19 09:18:42 +03:00
phpstan.neon.dist first commit 2025-10-19 09:18:42 +03:00
phpunit.xml.dist first commit 2025-10-19 09:18:42 +03:00
psalm.xml first commit 2025-10-19 09:18:42 +03:00
README.md first commit 2025-10-19 09:18:42 +03:00
rector.php wip 2025-12-11 15:11:01 +02:00
SECURITY.md first commit 2025-10-19 09:18:42 +03:00
testbench.yaml first commit 2025-10-19 09:18:42 +03:00

GitHub Workflow Status Latest Version on Packagist Software License Total Downloads


This library provides extended validation attributes, casts, transformers, and type utilities for spatie/laravel-data. It enhances the powerful data transfer object pattern with additional validation rules, type conversions, and utilities designed for Laravel 11+ with PHP 8.4+.

Requirements

Requires PHP 8.4+ and Laravel 11+

Requires spatie/laravel-data 4.18+

Installation

composer require cline/data

Documentation

Quick Start

Using Validation Attributes

use Cline\Data\Attributes\Validation\{PresentIf, MissingIf};
use Spatie\LaravelData\Data;

class OrderData extends Data
{
    public function __construct(
        #[PresentIf('type', 'premium')]
        public ?string $upgradeOption = null,

        #[MissingIf('automatic_renewal', true)]
        public ?int $renewalDays = null,
    ) {}
}

Using Casts and Transformers

use Cline\Data\Casts\{TrimCast, UpperCaseCast, NumberLikeCast};
use Spatie\LaravelData\Data;

class UserData extends Data
{
    public function __construct(
        #[TrimCast, UpperCaseCast]
        public string $name,

        #[NumberLikeCast]
        public int $accountId,
    ) {}
}

Using Type Utilities

use Cline\Data\Types\{StringLike, BooleanLike, NumberLike};

// Coerce values to appropriate types
$stringValue = StringLike::coerce('hello');
$boolValue = BooleanLike::coerce('true');
$numberValue = NumberLike::coerce('42.5');

Change log

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please use the GitHub security reporting form rather than the issue queue.

Credits

License

The MIT License. Please see License File for more information.