Skip to main content

Using the WithoutValidation attribute

You can skip validation for specific properties by using the #[WithoutValidation] attribute:
In this example, the internal_note property will not be validated, even though other properties have validation rules.
This is useful for properties that should bypass validation, such as computed values, internal flags, or data that’s already been validated elsewhere.
Sometimes you don’t want properties to be automatically validated, for instance when you’re manually overwriting the rules method like this:
When a request is being validated, the rules will look like this:
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:
Now the validation rules will look like this:

Skipping validation for all properties

By using data 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

Using config