Intervention / Intervention/validation
[Question] Use the rule patterns somewhere else
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 678
- Forks
- 68
- Avg merge
- 9m
- Merged PRs (30d)
- 1
Description
Hi! First of all, thank you for creating this package, it’s really helpful!
My problem
We’re building an application that processes user information, and we use the PostalCode rule to validate the postal codes provided in requests. The validation itself works perfectly, but I’m struggling with one thing: I’m generating a Swagger (OpenAPI) documentation for our APIs, and in it, I’d like to specify a pattern for the postal code like this:
new OA\Property(
property: 'postal_code',
type: 'string',
pattern: '^\d{4}[A-Z]{2}$'
),
But now I want to match the pattern used in Intervention\Validation\Rules\Postalcode, which seems a bit difficult. Besides, the pattern function is private, and it doesn't seem to accept functions in the Swagger documentation anyway. I'm currently using a public constant or an enum.
My questions
Has anyone had the same problem in the past? Did you solve it in some way, or did you just hardcode the pattern in your docs and hope it never changes within the package? Is there a way to fetch the pattern(s) that I just didn't see before?
Hope someone can help me out, Thnx
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Intervention\Validation\Rules\Postalcode and its private pattern function, then review the OpenAPI Property example in the issue. Determine whether the package should expose the rule pattern for API documentation without requiring duplicated hardcoded values; done means the intended approach and its behavior are documented or covered by an appropriate test.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- openapi, php
- Domain
- documentation
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100