def AsValidator(validator):
 if isinstance(validator, (str, unicode)):
  return Regex(validator, type(validator))
 if isinstance(validator, type):
  return Type(validator)
 if isinstance(validator, (list, tuple, set)):
  return Options(*tuple(validator))
 if isinstance(validator, Validator):
  return validator
 else:
  raise AttributeDefinitionError(('%s is not a valid validator' % str(validator)))

def AsValidator ( validator ) : if isinstance ( validator , ( str , unicode ) ) : return Regex ( validator , type ( validator ) ) if isinstance ( validator , type ) : return Type ( validator ) if isinstance ( validator , ( list , tuple , set ) ) : return Options ( * tuple ( validator ) ) if isinstance ( validator , Validator ) : return validator else : raise AttributeDefinitionError ( ( '%s is not a valid validator' % str ( validator ) ) )
wrap various types as instances of a validator .