yada

2018-08-21T03:52:11.000100Z

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

2018-08-21T03:52:17.000100Z

Is there a way around this?

mccraigmccraig 2018-08-21T08:42:52.000100Z

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

maleghast 2018-08-21T08:59:31.000100Z

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

maleghast 2018-08-21T08:59:56.000100Z

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

malcolmsparks 2018-08-21T09:03:38.000100Z

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

maleghast 2018-08-21T09:04:38.000100Z

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

malcolmsparks 2018-08-21T09:07:44.000100Z

You can do it inline in the params decl.

maleghast 2018-08-21T09:15:18.000100Z

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

maleghast 2018-08-21T09:16:25.000100Z

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.

maleghast 2018-08-21T09:16:27.000200Z

?

malcolmsparks 2018-08-21T09:32:25.000100Z

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

malcolmsparks 2018-08-21T09:32:56.000100Z

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

malcolmsparks 2018-08-21T09:34:45.000100Z

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.

malcolmsparks 2018-08-21T09:35:27.000100Z

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

malcolmsparks 2018-08-21T09:36:15.000100Z

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

dominicm 2018-08-21T09:36:52.000100Z

It's somewhat relevant to the 4xx responses.

malcolmsparks 2018-08-21T09:37:35.000100Z

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

dominicm 2018-08-21T09:38:13.000100Z

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

maleghast 2018-08-21T11:44:23.000100Z

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