Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MultiSource Parameter Type #49

Merged
merged 6 commits into from
Jul 11, 2024
Merged

Add MultiSource Parameter Type #49

merged 6 commits into from
Jul 11, 2024

Conversation

smt5541
Copy link
Collaborator

@smt5541 smt5541 commented Jul 1, 2024

🛠 Changes being made

Give examples of the changes you've made in this pull request. Include an itemized list if you can.

  • Add Parameter subclass MultiSource
  • Update ValidateParameters#validate to handle expected_delivery_types as a list of Parameters, return the first successful match, or error if no match found in any of the types

🧠 Rationale behind the change

Why did you choose to make these changes?

  • It would be useful in certain cases to be able to accept parameters from multiple sources, possibly spanning multiple HTTP methods.

Does this pull request resolve any open issues?

Yes. Closes #43

Were there any trade-offs you had to consider?

Usage syntax and behavior customization:

string: str = MultiSource(Query, Json, min_int=0) - can't specify validation conditions per parameter type, but it's easier to write out
string: str = MultiSource([Query(min_int=0), Json(min_int=0) - could allow for more customization in usage, but for the average user it's a worse experience

🧪 Testing

  • Have tests been added or updated for the changes introduced in this pull request?

  • Are the changes backwards compatible?

If the changes aren't backwards compatible, what other options were explored?

✨ Quality check

  • Are your changes free of any erroneous print statements, debuggers or other leftover code?

  • Has the README been updated to reflect the changes introduced (if applicable)?

💬 Additional comments

Feel free to add any further information below

Dependent on #45

@smt5541 smt5541 requested a review from Ge0rg3 July 1, 2024 21:51
@smt5541 smt5541 self-assigned this Jul 1, 2024
@smt5541 smt5541 added the enhancement New feature or request label Jul 1, 2024
@smt5541 smt5541 changed the title Dev/smt5541/multi source Add MultiSource Parameter Type Jul 1, 2024
@Ge0rg3
Copy link
Owner

Ge0rg3 commented Jul 11, 2024

Great addition, many thanks

@Ge0rg3 Ge0rg3 merged commit 1db7e5a into master Jul 11, 2024
1 check passed
@Ge0rg3 Ge0rg3 deleted the dev/smt5541/multi_source branch July 11, 2024 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Validating both Post and Get
2 participants