lighthouse icon indicating copy to clipboard operation
lighthouse copied to clipboard

Custom validation attributes

Open MrJmpl3 opened this issue 5 years ago • 1 comments

What problem does this feature proposal attempt to solve?

Looking the validation docs, I found a function: "Validation custom attributes".

The function can replace the ":attribute" in the errors messages, but I saw validation directive have a three rare custom validation. https://github.com/nuwave/lighthouse/blob/4.x/src/Schema/Directives/ValidationDirective.php#L46

Why? @spawnia

Which possible solutions should be considered?

  • Remove the three rare custom validation (because the custom attributes if only to rename attributes name)
    • Add a function attributes and return a array (like messages)
    • In the make function of ValidationFactory, assign the values returned from the new attributes function
    • Check if the code has same code copied (like FieldFactory)

https://laravel.com/docs/6.x/validation#customizing-the-validation-attributes

MrJmpl3 avatar Nov 13 '20 00:11 MrJmpl3

Validation has been completely revamped, you can check out the latest master and see how your desired change might fit in there. Open for PR's.

spawnia avatar Nov 13 '20 13:11 spawnia