Hi,
I am needing to expose APIs from OutSystems but these will need a lot of validations done. I have read on the forum that even if your input structure for a POST API has length set for fields and IsMandatory, that OS does not actually validate these and just accepts all inputs - which is a bit of a problem. So I am hoping there is a way to validate these myself by somehow accessing the structure of the input and comparing it's rules (such as length, data type and IsMandatory) to the input in that structure...
Is there any way to do this perhaps using JavaScript? Is there a way I can access this meta data of this structure using code so that I can compare it?
Thanks in advance!
Nic
There is no auto validation, you need to do it manually input by input.
Outsystems works with JSON preferably. In REST/JSON there is no standard validation method as far as i know.
For XML you can implement an XSD and validate content with that XSD. In Outsystems you can do that too ofcourse.
So, i am afraid you will have to create your own validation action.
Hi Nicholas,
if you're using REST APIs you can use callbacks (OnRequest) to perform those validations even before the request reaches your API.
Regards
Yes you can, but i am not sure if this is the best place to do that.
- The OnRequest is the same for all methods.
- The OnRequest will be triggered even before the OnAuthorization.
Why not perform the valiation of the input of the attributes of your structure inside the method itself?
Yes you're right, I was thinking only for 1 API case.
Inside the method should work better.
Hi all,
Thanks for the replies. However, I am not concerned about where I validate the inputs but how...
I am wanting to find an easier way to check the mandatory attributes than using an IF statement for each of them, I would like to somehow use the settings I already made within the input structure to test things like IsMandatory, length, DataType etc.
Any ideas?
Thanks, that is quite a pity. And is there a possibility to access the meta data of the structure in the browser using JavaScript to see if it should be Mandatory or do I have to pre-program that check manually?
With mandatory you would only check if the JSON field exists in the request. But if it exists and someone sends "", it would be valid.
I don't think you can avoid doing the validation yourself.