def choice_in(choices, ignore_case=False):
 if ignore_case:
  choice_set = frozenset(((e.upper() if isinstance(e, basestring) else e) for e in choices))
 else:
  choice_set = frozenset(choices)
 def validator(value):
  if (not isinstance(value, collections.Hashable)):
   raise ValidationError('Must specify a single choice; value cannot be a collection')
  if (ignore_case and isinstance(value, basestring)):
   value = value.upper()
  if (value in choice_set):
   return True
  else:
   raise ValidationValueError('Value must be one of these options: {}'.format(choices))
 return validator

def choice_in ( choices , ignore_case = False ) : if ignore_case : choice_set = frozenset ( ( ( e . upper ( ) if isinstance ( e , basestring ) else e ) for e in choices ) ) else : choice_set = frozenset ( choices ) def validator ( value ) : if ( not isinstance ( value , collections . Hashable ) ) : raise ValidationError ( 'Must specify a single choice; value cannot be a collection' ) if ( ignore_case and isinstance ( value , basestring ) ) : value = value . upper ( ) if ( value in choice_set ) : return True else : raise ValidationValueError ( 'Value must be one of these options: {}' . format ( choices ) ) return validator
validate that the option provided is one of a restricted set of choices returns a callable that can be used as a validator in modularodm .