Script for length validation


I want to validate ‘name’ field for certain character length.
For example when name contains more then 15 characters , script should get only first 15 characters and truncate rest of them.
Please help


@netgains do you have an example of what you’ve tried thus far? Also, what scripting language are you using? Please be more specific if you need help.


payload = event.request.payload

if payload:
if ‘name’ not in payload:
raise ValueError(‘User name field missing’)

user_name = payload.first_name

if user_name == ‘’:
raise ValueError(‘User name field required’)

response = platform.api.get(‘system/user?api_key=’ + API_KEY + ‘&filter=first_name%3D’ + user_name)
response_string =‘utf-8’)
response_bunch = bunchify(json.loads(response_string))

if response_bunch.resource:
raise ValueError(‘User name is not available’)


I have also user this:-

var lodash = require(“lodash.min.js”);

if (event.request.payload.resource) {

lodash._.each(event.request.payload.resource, function( record ) {

    if ( > 15) {
        throw 'annual_revenue must be > 0';


Still wont work


Are you trying to do this when a user registers? What event triggers this script?

The python code you have is from my other post that has never worked, so I don’t recommend making calls to system/user until someone from DF’s helps out.


I am using Pre Process Event Scripts.