> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/spatie/laravel-data/llms.txt
> Use this file to discover all available pages before exploring further.

# Skipping Validation

> Learn how to skip validation for specific properties or entire data classes

## Using the WithoutValidation attribute

You can skip validation for specific properties by using the `#[WithoutValidation]` attribute:

```php theme={null}
use Spatie\LaravelData\Attributes\WithoutValidation;
use Spatie\LaravelData\Data;

class UserData extends Data
{
    public function __construct(
        #[Required]
        public string $name,
        #[Required, Email]
        public string $email,
        #[WithoutValidation]
        public ?string $internal_note,
    ) {
    }
}
```

In this example, the `internal_note` property will not be validated, even though other properties have validation rules.

<Tip>
  This is useful for properties that should bypass validation, such as computed values, internal flags, or data that's already been validated elsewhere.
</Tip>

Sometimes you don't want properties to be automatically validated, for instance when you're manually overwriting the
rules method like this:

```php theme={null}
use Illuminate\Http\Request;

class SongData extends Data
{
    public function __construct(
        public string $name,
    ) {
    }
    
    public static function fromRequest(Request $request): static{
        return new self("{$request->input('first_name')} {$request->input('last_name')}");
    }
    
    public static function rules(): array
    {
        return [
            'first_name' => ['required', 'string'],
            'last_name' => ['required', 'string'],
        ];
    }
}
```

When a request is being validated, the rules will look like this:

```php theme={null}
[
    'name' => ['required', 'string'],
    'first_name' => ['required', 'string'],
    'last_name' => ['required', 'string'],
]
```

We know we never want to validate the `name` property since it won't be in the request payload, this can be done as
such:

```php theme={null}
use Spatie\LaravelData\Attributes\WithoutValidation;

class SongData extends Data
{
    public function __construct(
        #[WithoutValidation]
        public string $name,
    ) {
    }
}
```

Now the validation rules will look like this:

```php theme={null}
[
    'first_name' => ['required', 'string'],
    'last_name' => ['required', 'string'],
]
```

## Skipping validation for all properties

By using [data factories](/as-a-dto/factories) or setting the `validation_strategy` in the `data.php` config you can skip validation for all properties of a data class.

### Using data factories

```php theme={null}
SongData::factory()->withoutValidation()->from($request);
```

### Using config

```php theme={null}
// config/data.php

'validation_strategy' => \Spatie\LaravelData\Support\Creation\ValidationStrategy::Disabled->value,
```
