Skip to content

Conversation

@Jasonej
Copy link
Contributor

@Jasonej Jasonej commented Nov 12, 2025

This PR adds setDefaultAttributesFormatter to allow for control over how attribute names are formatted in cases where the default str_replace('_', ' ', Str::snake($attribute)) logic is not desired.

This allows for something like:

Validator::make([], ['data.someAttribute' => 'required'])
    ->setDefaultAttributesFormatter(fn($attribute) => $attribute)
    ->validate()

Which would produce:

The data.someAttribute field is required.

Instead of:

The data.some attribute field is required.

This doesn't break existing behavior because it only applies when a defaultAttributesFormatter has been set on the validator.

@Jasonej Jasonej changed the title Validator default attributes formatter [12.x] Validator default attributes formatter Nov 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant