Fork me on GitHub
#yada
<
2018-08-21
>
frozenlock03:08:11

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'.

frozenlock03:08:17

Is there a way around this?

mccraigmccraig08:08:52

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

maleghast08:08:31

@mccraigmccraig - how does one allow for empty form fields..?

maleghast08:08:56

(I am getting a 400 'cos some of the params I've defined are not being supplied with a value)

malcolmsparks09:08:38

You can set keys to be optional with optional-key.

maleghast09:08:38

@malcolmsparks - Oh thanks, in the defschema (per Yada Manual)?

malcolmsparks09:08:44

You can do it inline in the params decl.

maleghast09:08:18

@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..?

maleghast09:08:25

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.

malcolmsparks09:08:25

Be careful going overboard with structure. I tend to write schema in place on a per resource basis

malcolmsparks09:08:56

Rich Hickey's talk on Effective Programming explains better than I can

malcolmsparks09:08:45

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.

malcolmsparks09:08:27

The reason for the overlap is mostly due to swagger support, which someday I'd like to separate out

malcolmsparks09:08:15

When I wrote yada swagger was very popular, like GraphQL today 😉

dominicm09:08:52

It's somewhat relevant to the 4xx responses.

malcolmsparks09:08:35

Yes, but yada could just be the messenger and leave the validation to a more focused library.

dominicm09:08:13

Yada just needs to know whether or not the params are valid, agree. Contract as a function likely would be suitable.

maleghast11:08:23

Thanks chaps - that all makes sense to me, and I will err on the side of "less is more" 😉