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

How to create an Entity with many attributes? #2

Closed
MortalFlesh opened this issue May 28, 2020 · 3 comments
Closed

How to create an Entity with many attributes? #2

MortalFlesh opened this issue May 28, 2020 · 3 comments

Comments

@MortalFlesh
Copy link

Hello,
first of all, thanks for this library!

I'm trying to create a Resource, by operation.Post, but I'm not sure how to do it correctly.

There are just a couple of attributes in the example, I have 15 attributes at my Resource and the RequestParser can't handle all of them.

I've found it in the code here https://github.com/cmeeren/Felicity/blob/master/src/Felicity/RequestParser.fs#L474, it says
// TODO: Higher arities

So is there any other way how to create a resource with that many attributes now?


What I have in mind is try to parse all attributes on my own in the Post function, and create a resource on my own. Then just pass the resource to the Parser, but I don't think it is a "correct" way to do it, since the parse won't do "parsing" in that case.

Also, I'm not sure how to use defined attributes in this way.

@cmeeren
Copy link
Owner

cmeeren commented May 28, 2020

Hi! Does this section in the docs answer your question? You can parse however many parameters you want that way, it's just that you won't get the errors combined.

Other than that, more parameters can always be added, but this is what arity 6 implementation looks like, so it would be a lot of code.

By the way, the parsing may be changed to be simpler once F# supports the applicative and! keyword for CEs. Due to arrive in F# 5. That would allow combining errors for arbitrarily many parameters.

@MortalFlesh
Copy link
Author

Oh I missed this in the docs, this is exactly what I need! I wasn't sure how to use a job in my code.
Also this explains how and! will work 💡!

Thanks for quick reply.

@cmeeren
Copy link
Owner

cmeeren commented May 28, 2020

No problem. There is also an Async<Result<_,_>> overload where you can use an asyncResult CE instead of jobResult, if you'd rather use that (so you don't need to use FsToolkit.ErrorHandling.JobResult).

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

No branches or pull requests

2 participants