################################################################################
# Example validator code

# validate your variables here
n = context.REQUEST.get('n', None)
if not n:
   state.setError('n', 'Please enter a value for n')

if state.getErrors():
   # An error has occurred.  Set the status to 'failure' 
   # (the default initial status is 'success')
   state.setStatus('failure')
   # Return the state and pass the variable portal_status_message in the REQUEST
   return state.set(portal_status_message='Please correct the errors shown')

# No errors.  Always make sure to return the ControllerState object
return state