I'm trying to intercept a query parameters before sending everything to a single page application. However, if I declare the query parameter I want in the yada resource, then the other parameters (used in my SPA) are 'disallowed'.
Is there a way around this?
the parameter schema declared for the yada resource should match the submitted parameters @frozenlock - you can add a {schema/Keyword schema/Any}
to the parameter schema as described above to allow any old params if you need
@mccraigmccraig - how does one allow for empty form fields..?
(I am getting a 400 'cos some of the params I've defined are not being supplied with a value)
You can set keys to be optional with optional-key.
@malcolmsparks - Oh thanks, in the defschema (per Yada Manual)?
You can do it inline in the params decl.
@malcolmsparks - Thanks 🙂 I've done it in a defschema for now, I may move it around... I was wondering... Can I define multiple schema and have a form that is actually made up of lots of different data be automatically split up into Org, User, Address etc..?
Or am I better off working on a bunch of functions to transform a catch-all data structure for the form into specific "things" that I want to have available to me.
?
Be careful going overboard with structure. I tend to write schema in place on a per resource basis
Rich Hickey's talk on Effective Programming explains better than I can
The parameter validation in yada is arguably not an http concern and shouldn't be in yada. There are other more capable libs for validating data and processing it.
The reason for the overlap is mostly due to swagger support, which someday I'd like to separate out
When I wrote yada swagger was very popular, like GraphQL today 😉
It's somewhat relevant to the 4xx responses.
Yes, but yada could just be the messenger and leave the validation to a more focused library.
Yada just needs to know whether or not the params are valid, agree. Contract as a function likely would be suitable.
Thanks chaps - that all makes sense to me, and I will err on the side of "less is more" 😉