Custom attribute writer method checking allowed values (enum).
 @param [Object] event Object to be assigned
429347
def event=(event)
      validator = EnumAttributeValidator.new('String', ["video-passed", "video-error", "video-warning", "video-rejected", "video-canceled"])
      unless validator.valid?(event)
        fail ArgumentError, "invalid value for 'event', must be one of #{validator.allowable_values}."
      end
      @event = event
    end
140398
def translate_enum(attribute, &block)
      builder = Builder.new(self, attribute, &block)

      # User.translated_status(:active)
      define_singleton_method(builder.method_name_singular) do |key|
        I18n.translate("#{builder.i18n_scope}.#{builder.i18n_location(key)}", default: builder.i18n_default_location(key))
      end

      # @return [Array]
      # @example
      #   f.select_field :gender, f.object.class.translated_genders
      define_singleton_method(builder.method_name_plural) do
        public_send(builder.enum_klass_method_name).map do |key, value|
          [public_send(builder.method_name_singular, key), key, value]
        end
      end

      # @return [String]
      # @example
      #   @user.translated_gender
      define_method(builder.method_name_singular) do
        if (key = public_send(builder.enum_instance_method_name)).present?
          self.class.public_send(builder.method_name_singular, key)
        end
      end
    end
299620
function (attr, attrName) {
            if (_.isObject(attr) && !_.isDate(attr) && !_.isBoolean(attr) && !_.isString(attr) && !_.isNumber(attr) && !_.isFunction(attr) && !_.isRegExp(attr) && !_.isArray(attr)) {
                //attr = _removeAttributes();
                for (var aIndex in attr) {
                    attr[aIndex] = _removeAttributes(attr[aIndex], aIndex);
                }
                return attr;
            }
            else {
                if (_.indexOf(allowedAttributes, attrName) != -1) {
                    if (_.isFunction(attr)) {
                        attr = _functionName(attr);
                    }

                    return attr;
                }
                else {
                    return;
                }
            }
        }
293206
function (event) {
                var specialKey = false, keyCode = event.keyCode;
                for (var index = 0, keyMap; index < this.selectionKeys.length; index++) {
                    keyMap = this.selectionKeys[index];
                    if (this._validateModifiers(keyMap, event)) {
                        // case real key defined. For eg: 65 for a
                        if (ariaUtilsType.isNumber(keyMap.key)) {
                            if (keyMap.key === keyCode) {
                                specialKey = true;
                                break;
                            }
                        } else if (typeof(keyMap.key) !== "undefined"
                                && event["KC_" + keyMap.key.toUpperCase()] == keyCode) {
                            specialKey = true;
                            break;
                        } else if (typeof(keyMap.key) !== "undefined"
                                && String.fromCharCode(event.charCode) == keyMap.key) {
                            specialKey = true;
                            break;
                        }
                    }
                }
                return specialKey;
            }
327159
function(event) {
			var inst = plugin._getInst((event.data && event.data.elem) || event.target);
			if (!$.isEmptyObject(inst) && inst.options.constrainInput) {
				var ch = String.fromCharCode(event.keyCode || event.charCode);
				var allowedChars = plugin._allowedChars(inst);
				return (event.metaKey || inst.ctrlKey || ch < ' ' ||
					!allowedChars || allowedChars.indexOf(ch) > -1);
			}
			return true;
		}
1165920
function (event) {
            // Check if the node is a child of the plugin's element.
            if (event.relatedNode === this.element) {
                var attributeValues = event.target.getAttribute("data-validate");
                if (attributeValues !== null) {
                    attributeValues = this.splitStringByComma(attributeValues);
                    for (var x = 0; x < attributeValues.length; x++) {
                        var key = attributeValues[x];
                        if (key === undefined || key === null)
                            continue;
                        this.validate[key].push(event.target);
                    }
                }
                if (event.target.hasAttribute("data-length") &&
                    this.validate["length"].indexOf(event.target) === -1)
                    this.validate["length"].push(event.target);
            }
        }
595562
def inclusion_type=(inclusion_type)
      validator = EnumAttributeValidator.new('String', ["ADDITIVE", "INCLUSIVE"])
      unless validator.valid?(inclusion_type)
        fail ArgumentError, "invalid value for 'inclusion_type', must be one of #{validator.allowable_values}."
      end
      @inclusion_type = inclusion_type
    end
1196450
protected void checkXmlSpaceAttr(int type, WordResolver enumValues)
        throws XMLStreamException
    {
        boolean ok = (type == DTDAttribute.TYPE_ENUMERATED);
        if (ok) {
            switch (enumValues.size()) {
            case 1:
                ok = (enumValues.find("preserve") != null)
                    || (enumValues.find("default") != null);
                break;
            case 2:
                ok = (enumValues.find("preserve") != null)
                    && (enumValues.find("default") != null);
                break;
            default:
                ok = false;
            }
        }
        
        if (!ok) {
            _reportVCViolation(ErrorConsts.ERR_DTD_XML_SPACE);
        }
    }
1127111
function _onAttributeModified(event, res) {
        // res = {nodeId, name, value}
        var matches = /^data-ld-(.*)/.exec(res.name);
        if (matches) {
            exports.trigger(matches[1], res);
        }
    }
712484
def strict=(strict)
      validator = EnumAttributeValidator.new('String', ["none"])
      unless validator.valid?(strict)
        fail ArgumentError, "invalid value for 'strict', must be one of #{validator.allowable_values}."
      end
      @strict = strict
    end
1066144
def valid?
      sort_validator = EnumAttributeValidator.new('String', ["COUNT", "INDEX"])
      return false unless sort_validator.valid?(@sort)
      method_validator = EnumAttributeValidator.new('String', ["ENUM", "FC"])
      return false unless method_validator.valid?(@method)
      return true
    end
1288012
def can_use_enum(func):
    

    @wraps(func)
    def inner(self, value):
        if isinstance(value, Enum):
            return self.check_value(value.value) or func(self, value.value)

        return func(self, value)

    return inner
28811
def _validate_user_inputs(self, attributes=None, event_tags=None):
    

    if attributes and not validator.are_attributes_valid(attributes):
      self.logger.error('Provided attributes are in an invalid format.')
      self.error_handler.handle_error(exceptions.InvalidAttributeException(enums.Errors.INVALID_ATTRIBUTE_FORMAT))
      return False

    if event_tags and not validator.are_event_tags_valid(event_tags):
      self.logger.error('Provided event tags are in an invalid format.')
      self.error_handler.handle_error(exceptions.InvalidEventTagException(enums.Errors.INVALID_EVENT_TAG_FORMAT))
      return False

    return True
987290
static void forceWritingEnumValue(
        VerboseXmlEncoder encoder, Object object)
    {
        Field valueToExpressionField = null;
        Field refsField = null;
        try
        {
            Class<?> encoderClass = encoder.getClass().getSuperclass();
            valueToExpressionField = 
                encoderClass.getDeclaredField("valueToExpression");
            valueToExpressionField.setAccessible(true);
            Object valueToExpressionObject = 
                valueToExpressionField.get(encoder);
            Map<?,?> valueToExpression = (Map<?,?>)valueToExpressionObject;
            Object valueData = valueToExpression.get(object);
            if (valueData != null)
            {
                Class<?> valueDataClass = valueData.getClass(); 
                refsField = valueDataClass.getDeclaredField("refs");
                refsField.setAccessible(true);
                refsField.setInt(valueData, 0);
            }
        }
        catch (NoSuchFieldException e)
        {
            logger.warning(e.toString());
        }
        catch (SecurityException e)
        {
            logger.warning(e.toString());
        }
        catch (IllegalArgumentException e)
        {
            logger.warning(e.toString());
        }
        catch (IllegalAccessException e)
        {
            logger.warning(e.toString());
        }
        finally
        {
            if (valueToExpressionField != null)
            {
                valueToExpressionField.setAccessible(false);
            }
            if (refsField != null)
            {
                refsField.setAccessible(false);
            }
        }
    }
1026761
def _handle_enum(self, node, scope, ctxt, stream):
        
        self._dlog("handling enum")
        if node.type is None:
            enum_cls = fields.Int
        else:
            enum_cls = self._handle_node(node.type, scope, ctxt, stream)

        enum_vals = {}
        curr_val = enum_cls()
        curr_val._pfp__value = -1
        for enumerator in node.values.enumerators:
            if enumerator.value is not None:
                curr_val = self._handle_node(enumerator.value, scope, ctxt, stream)
            else:
                curr_val = curr_val + 1
            curr_val._pfp__freeze()
            enum_vals[enumerator.name] = curr_val
            enum_vals[fields.PYVAL(curr_val)] = enumerator.name
            scope.add_local(enumerator.name, curr_val)

        if node.name is not None:
            enum_cls = EnumDef(node.name, enum_cls, enum_vals)
            scope.add_type_class(node.name, enum_cls)

        else:
            enum_cls = EnumDef("enum_" + enum_cls.__name__, enum_cls, enum_vals)
            # don't add to scope if we don't have a name

        return enum_cls
11713
def sort=(sort)
      validator = EnumAttributeValidator.new('String', ["COUNT", "INDEX"])
      unless validator.valid?(sort)
        fail ArgumentError, "invalid value for 'sort', must be one of #{validator.allowable_values}."
      end
      @sort = sort
    end
532688
def _setup_validation(self, sender, **kwargs):
        
        att_name = self.get_attname()
        private_att_name = '_enum_%s' % att_name
        enum = self.enum

        def set_enum(self, new_value):
            if hasattr(self, private_att_name):
                # Fetch previous value from private enum attribute.
                old_value = getattr(self, private_att_name)
            else:
                # First setattr no previous value on instance.
                old_value = new_value
            # Update private enum attribute with new value
            setattr(self, private_att_name, new_value)
            self.__dict__[att_name] = new_value
            # Run validation for new value.
            validators.validate_valid_transition(enum, old_value, new_value)

        def get_enum(self):
            return getattr(self, private_att_name)

        def delete_enum(self):
            self.__dict__[att_name] = None
            return setattr(self, private_att_name, None)

        if not sender._meta.abstract:
            setattr(sender, att_name, property(get_enum, set_enum, delete_enum))