TODO perhaps add a list of allowed properties and their values
497568
public void addProperty(String name, String value, int valueIndex) {
        if(name == null || name.isEmpty()) {
            throw new IllegalArgumentException("Invalid property name: " + name);
        }
        if(value == null || value.isEmpty()) {
            throw new IllegalArgumentException("Invalid property value: " + value);
        }
        if(props == null) {
            props = new HashMap<String,String>();
        }
        props.put(name, value);
        this.lastPropertyName = name;
        this.lastPropertyValue = value;
        this.lastChunkIndex = valueIndex;
        separator = -1;
    }
1282831
def allowed_values(self):
        
        data = clips.data.DataObject(self._env)

        lib.EnvDeftemplateSlotAllowedValues(
            self._env, self._tpl, self._name, data.byref)

        return tuple(data.value) if isinstance(data.value, list) else ()
1313687
function validateProperty(object, value, property, schema, options, errors, indexInArray, array) {
    var valid,
        type;

    function constrain(name, value, assert) {
      if (schema[name] !== undefined && !assert(value, schema[name])) {
        error(name, property, value, schema, errors);
      }
    }

    //validate default value
    if (options.validateDefaultValue && schema['default'] !== undefined &&
        property != 'default') {
      validateProperty(schema, schema['default'], 'default', schema, options, errors);
    }

    if (value === undefined) {
      //apply default value if have an option and default value
      if (options.applyDefaultValue && schema['default'] !== undefined) {
        value = schema['default'];
        object[property] = value;
        return;
      } else if (schema.required) {
        var required = schema.required;
        if (typeof required === 'function') {
          required = required(object, property);
        }
        if (required && schema.type !== 'any') {
          return error('required', property, undefined, schema, errors);
        } else {
          return;
        }
      } else {
        return;
      }
    }

    if (options.cast) {
      if (('integer' === schema.type || 'number' === schema.type) && value == +value) {
        value = +value;
      }

      if ('boolean' === schema.type) {
        if ('true' === value || '1' === value || 1 === value) {
          value = true;
        }

        if ('false' === value || '0' === value || 0 === value) {
          value = false;
        }
      }

      if ('date' === schema.type) {
        value = new Date(value);
      }
      //modify source object if we have an option and values are differ
      //for simple value
      if (options.castSource && indexInArray == null && object[property] !== value) {
        object[property] = value;
      } else
        if (options.castSource && indexInArray != null && array[indexInArray] !== value) {
          //and for an array
          array[indexInArray] = value;
        }
    }

    if (schema['enum'] && schema['enum'].indexOf(value) === -1) {
      error('enum', property, value, schema, errors);
    }

    // Dependencies (see 5.8)
    if (typeof schema.dependencies === 'string' &&
        object[schema.dependencies] === undefined) {
      error('dependencies', property, null, schema, errors);
    }

    if (isArray(schema.dependencies)) {
      for (var i = 0, l = schema.dependencies.length; i < l; i++) {
        if (object[schema.dependencies[i]] === undefined) {
          error('dependencies', property, null, schema, errors);
        }
      }
    }

    if (typeof schema.dependencies === 'object') {
      var oldAdditionalProperties = options.additionalProperties;
      options.additionalProperties = true;
      validateObject(object, schema.dependencies, options, errors);
      options.additionalProperties = oldAdditionalProperties;
    }

    checkType(value, schema.type, function(err, type) {
      var errorsCountBeforeCheckType = errors.length;
      if (err) return error('type', property, typeof value, schema, errors);

      constrain('conform', value, function (a, e) { return e(a, object, property) });

      switch (type || (isArray(value) ? 'array' : typeof value)) {
        case 'string':
          constrain('minLength', value.length, function (a, e) { return a >= e });
          constrain('maxLength', value.length, function (a, e) { return a <= e });
          constrain('pattern',   value,        function (a, e) {
            e = typeof e === 'string'
              ? e = new RegExp(e)
              : e;
            return e.test(a)
          });
          if (options.validateFormats) {
            constrain('format', value, function(value, format) {
              var spec;
              if (options.validateFormatExtensions) {
                spec = validate.formatExtensions[format];
              }
              if (!spec) {
                spec = validate.formats[format];
              }
              if (spec) {
                return spec.test(value);
              } else {
                return !options.validateFormatsStrict;
              }
            });
          }
          break;
        case 'integer':
        case 'number':
          constrain('minimum',     value, function (a, e) { return a >= e });
          constrain('maximum',     value, function (a, e) { return a <= e });
          constrain('exclusiveMinimum', value, function (a, e) { return a > e });
          constrain('exclusiveMaximum', value, function (a, e) { return a < e });
          constrain('divisibleBy', value, function (a, e) {
            var multiplier = Math.max((a - Math.floor(a)).toString().length - 2, (e - Math.floor(e)).toString().length - 2);
            multiplier = multiplier > 0 ? Math.pow(10, multiplier) : 1;
            return (a * multiplier) % (e * multiplier) === 0
          });
          break;
        case 'array':
          constrain('items', value, function (a, e) {
            for (var i = 0, l = a.length; i < l; i++) {
              validateProperty(object, a[i], property, e, options, errors, i, a);
            }
            return true;
          });
          constrain('minItems', value, function (a, e) { return a.length >= e });
          constrain('maxItems', value, function (a, e) { return a.length <= e });
          constrain('uniqueItems', value, function (a) {
            var h = {};

            for (var i = 0, l = a.length; i < l; i++) {
              var key = JSON.stringify(a[i]);
              if (h[key]) return false;
              h[key] = true;
            }

            return true;
          });
          break;
        case 'object':
          // Recursive validation
          if (schema.properties || schema.patternProperties || schema.additionalProperties) {
            validateObject(value, schema, options, errors);
          }
          break;
      }

      //schema filtering
      if (schema.filter && errorsCountBeforeCheckType == errors.length) {
        if (type != 'array' && type != 'object') {
          var filters = isArray(schema.filter) ? schema.filter : [schema.filter];
          for (var i = 0, l = filters.length; i < l; i++) {
            var filter = null;
            if (isString(filters[i])) {
              if (filters[i] in validate.filters) {
                filter = validate.filters[filters[i]];
              } else {
                return error('filter', property, filters[i], schema, errors, 'unknown filter: %{actual}');
              }
            } else if (isFunction(filters[i])) {
              filter = filters[i];
            } else {
              return error('filter', property, typeof filters[i], schema, errors, 'bad filter type: %{actual}');
            }
            try {
              // filter value for simple value or for an array item
              if (indexInArray == null) {
                object[property] = filter(object[property]);  
              } else {
                object[property][indexInArray] = filter(object[property][indexInArray]);
              }
            } catch(err) {
              return error('filter', property, err, schema, errors, 'error during filtering: %{actual}');
            }
          }
        } else {
          return error('filter', property, type, schema, errors, 'bad property type for filtering: %{actual}');
        }
      }
    });
  }
791611
function (data) {
    // Add property to hold internal values
    Object.defineProperty(this, '_', {
        enumerable: false,
        configurable: false,
        writable: false,
        value: {
            dt: this._clone(data),
            ev: {},
            df: {},
            sp: false,
            ct: 0
        }
    });
    // Assign keys
    for (var key in this._.dt) {
        this._addProperty(key);
    }
}
530122
@SuppressWarnings("deprecation")
    public BUILDER setAllowedValues(String ... allowedValues) {
        assert allowedValues!= null;
        this.allowedValues = new ModelNode[allowedValues.length];
        for (int i = 0; i < allowedValues.length; i++) {
            this.allowedValues[i] = new ModelNode(allowedValues[i]);
        }
        return (BUILDER) this;
    }
957715
@Override
    public void property(String name, String value, int nameValueSeparatorIndex)
            throws OperationFormatException {

        if(name != null) {
            // TODO this is not nice
            if(name.length() > 1 && name.charAt(0) == '-' && name.charAt(1) == '-') {
                assertValidParameterName(name.substring(2));
            } else if(name.length() > 0 && name.charAt(0) == '-') {
                assertValidParameterName(name.substring(1));
            } else {
                assertValidParameterName(name);
            }
        }

        if (value.isEmpty()) {
            throw new OperationFormatException("Parameter '" + value + "' is missing value.");
        }

        validatedProperty(name, value, nameValueSeparatorIndex);
    }
1036714
private static void addAttrCondition(final List<Condition> conditions, final String name, Object value) {
    if (value instanceof String) {
      if (Strings.isBlank((String) value)) { return; }
      StringBuilder content = new StringBuilder(name);
      content.append(" like :").append(name.replace('.', '_'));
      conditions.add(new Condition(content.toString(), "%" + value + "%"));
    } else if (value instanceof Component) {
      conditions.addAll(extractComponent(name, (Component) value));
      return;
    } else if (value instanceof Entity<?>) {
      try {
        final String key = "id";
        Object property = PropertyUtils.getProperty(value, key);
        if (ValidEntityKeyPredicate.Instance.apply(property)) {
          StringBuilder content = new StringBuilder(name);
          content.append('.').append(key).append(" = :").append(name.replace('.', '_')).append('_')
              .append(key);
          conditions.add(new Condition(content.toString(), property));
        }
      } catch (Exception e) {
        logger.warn("getProperty " + value + "error", e);
      }
    } else {
      conditions.add(new Condition(name + " = :" + name.replace('.', '_'), value));
    }
  }
998539
public void addProperty(final String propertyName, final String value) {
        Preconditions.checkNotNull(propertyName);
        Preconditions.checkNotNull(value);
        List<String> values = properties.get(propertyName);
        if (values == null) {
            values = new ArrayList<>();
            values.add(value);
            properties.put(propertyName, values);
        } else {
            values.add(value);
        }
    }
1190168
@SuppressWarnings("unchecked")
  public static void checkProperties(Properties properties, Properties defaults) {
    Set<String> names = Generics.newHashSet();
    for (Enumeration<String> e = (Enumeration<String>) properties.propertyNames();
         e.hasMoreElements(); ) {
      names.add(e.nextElement());
    }
    for (Enumeration<String> e = (Enumeration<String>) defaults.propertyNames();
         e.hasMoreElements(); ) {
      names.remove(e.nextElement());
    }
    if (!names.isEmpty()) {
      if (names.size() == 1) {
        throw new IllegalArgumentException("Unknown property: " + names.iterator().next());
      } else {
        throw new IllegalArgumentException("Unknown properties: " + names);
      }
    }
  }
871549
function(field, allowedValues) {
    if (Array.isArray(field)) {
      return this.validateFieldsHelper(
        field,
        [allowedValues],
        this.validatesInclusionOf
      )
    }

    return this.validates(field, function() {
      var valid = true
      if (this[field]) valid = allowedValues.indexOf(this[field]) !== -1
      if (!valid)
        this.errors.add(
          field,
          'only allow one of [' + allowedValues.join(', ') + ']'
        )
      return valid
    })
  }
1135755
function addMetaProperty (object, propName, value) {
  defineProperty(object, propName, {
    enumerable: false,
    value
  })
}
1204455
function (param, allowTypes) {
    var t$ = Tool;
    allowTypes = allowTypes || [];
    if (t$.isUndefinedOrNull(param)) { return [] }
    if (allowTypes.findIndex(function (value, index, err) {
      return value === t$.getType(param)
    }) > -1) {
      return [param]
    }
    if (t$.isArray(param)) { return param }
    return []
  }
1252638
public function listInvalidProperties()
    {
        $invalidProperties = [];

        if ($this->container['created'] === null) {
            $invalidProperties[] = "'created' can't be null";
        }
        if ($this->container['name'] === null) {
            $invalidProperties[] = "'name' can't be null";
        }
        $allowedValues = $this->getNameAllowableValues();
        if (!in_array($this->container['name'], $allowedValues)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'name', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        if ($this->container['status'] === null) {
            $invalidProperties[] = "'status' can't be null";
        }
        $allowedValues = $this->getStatusAllowableValues();
        if (!in_array($this->container['status'], $allowedValues)) {
            $invalidProperties[] = sprintf(
                "invalid value for 'status', must be one of '%s'",
                implode("', '", $allowedValues)
            );
        }

        if ($this->container['updated'] === null) {
            $invalidProperties[] = "'updated' can't be null";
        }
        return $invalidProperties;
    }
632563
function permittedAttributes() {
        let filteredKeys = ghostBookshelf.Model.prototype.permittedAttributes.apply(this, arguments);

        this.relationships.forEach((key) => {
            filteredKeys.push(key);
        });

        return filteredKeys;
    }
560381
function(properties) {
        var body = '  <d:set>\n' +
            '   <d:prop>\n';

        for(var ii in properties) {
            if (!properties.hasOwnProperty(ii)) {
                continue;
            }

            var property = this.parseClarkNotation(ii);
            var propName;
            var propValue = properties[ii];
            if (this.xmlNamespaces[property.namespace]) {
                propName = this.xmlNamespaces[property.namespace] + ':' + property.name;
            } else {
                propName = 'x:' + property.name + ' xmlns:x="' + property.namespace + '"';
            }

            // FIXME: hard-coded for now until we allow properties to
            // specify whether to be escaped or not
            if (propName !== 'd:resourcetype') {
                propValue = dav._escapeXml(propValue);
            }
            body += '      <' + propName + '>' + propValue + '</' + propName + '>\n';
        }
        body +='    </d:prop>\n';
        body +='  </d:set>\n';
        return body;
    }
921460
function validateProperties(object, name, required, optional) {
    // validates object properties exist or not
    var properties = _.keys(object);
    var missing = _.difference(required, properties);
    var extra = _.difference(properties, required, optional);
    var errorOrNull = null;
    if (missing.length) {
        errorOrNull = new VError("%s is missing required properties (%j)",
                               name, missing);
        errorOrNull.missing = missing;
        errorOrNull.required = required;
        errorOrNull.object = object;
    } else if (extra.length) {
        errorOrNull = new VError("%s has extra (unexpected) properties (%j)",
                               name, extra);
        errorOrNull.extra = extra;
        errorOrNull.required = required;
        errorOrNull.optional = optional;
        errorOrNull.object = object;
    }
    return errorOrNull;
}
880507
function sanitizeProperties(custom_properties) {
  var properties = _extends({}, default_properties, custom_properties);

  // convert button keyword to associated number
  if (typeof properties.button === 'string') {
    properties.button = button_keywords[properties.button];
  }

  return properties;
}