How to Perform Validation on Incoming Data


Is it possible to perform validation on incoming data?


Here’s a simple way to get post-mapping validation working (which means you can re-use the validation script in any mapping script which maps to the same grammar).  It could be abstracted with interfaces etc.

  1. Inside the usersys/mappings’ folder create a new folder; validation.

2. In the validation folder you must place a blank file (prefixed and postfixed with double underscores).

3. Create a validation script, e.g.:

import bots.botsglobal as botsglobal

def validate(out):'Validating sales order')
 deliveryName = out.get({'BOTSID':'HDR', 'Delname':None})

if not deliveryName:
 raise Exception('Delivery name not populated')

4. Now in your mapping script import botslib:

import bots.botslib as botslib

5. And at the bottom of your mapping script once you’ve populated out (the output grammar) import the validation script and call the validate method:

     strategixsovalidation,filename = botslib.botsimport('mappings', 'validation', 'salesorder')
 except ImportError:
     raise Exception('Unable to load validation script')

Leave a Reply

Your email address will not be published. Required fields are marked *