nuwave / nuwave/lighthouse

Custom validation attributes

Open
#1,610 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
PHP
Stars
3.5k
Forks
468
Avg merge
3h 9m
Merged PRs (30d)
2

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read src/Schema/Directives/ValidationDirective.php around line 46, then trace the ValidationFactory and FieldFactory areas named in the issue. Compare the current behavior with Laravel's custom validation-attribute documentation; done means the selected approach is applied consistently and the existing validation behavior remains covered.

Written by the indexing model from the issue text.

Assessment

Tech stack
graphql, laravel, php
Domain
backend-api-design
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.