This topic contains 2 replies, has 2 voices, and was last updated by
August 19, 2019 at 7:44 am #171409ParticipantTopics: 10Replies: 11Points: 122Rank: Participant
I have written a script (let's call it X.ps1) which pulls data from one system via a small API wrapper (A.psm1), manipulates it and then sends it via POST or PUT to a second system, via another API wrapper (B.psm1).
A.psm1 > X.ps1 > [do some stuff] > B.psm1
System B has some quirks, which mean that I need to validate the output from System A before sending it. E.g. if "Gender" is not "M" or "F", the request fails – this often causes issues if the field is empty/null in System A. Adding basic validation is simple enough, but I am not sure where to put it. Should X.ps1 check the data before invoking commands in B.psm1? Or should B.psm1 do the validation and send back warnings/errors to X.ps1 ?
August 19, 2019 at 8:36 am #171427ParticipantTopics: 1Replies: 23Points: 164Rank: Participant
I would manipulate the data in X so that it runs B with arguments. Tell B which parameters are mandatory and validate them.
August 19, 2019 at 9:36 am #171439ParticipantTopics: 10Replies: 11Points: 122Rank: Participant
So, to use my example, if X retrieves a record from A which includes Gender=null, it should be passed to B where validation will occur. X should then use try/catch to deal with the resulting validation error in B, rather than X checking the contents of the Gender field itself. This approach means X doesn't need to be aware of any changes to B (e.g. B may be updated to accept Gender=null later on).
Does that sound about right?
You must be logged in to reply to this topic.