upon leaving a field
 returns false if value not valid as per values or valid_regex
 2008-12-22 12:40 if null_allowed, don't validate, but do fire_handlers
490425
def on_leave
      val = getvalue
      #$log.debug " FIELD ON LEAVE:#{val}. #{@values.inspect}"
      valid = true
      if val.to_s.empty? && @null_allowed
        #$log.debug " empty and null allowed"
      else
        if !@values.nil?
          valid = @values.include? val
          raise FieldValidationException, "Field value (#{val}) not in values: #{@values.join(',')}" unless valid
        end
        if !@valid_regex.nil?
          valid = @valid_regex.match(val.to_s)
          raise FieldValidationException, "Field not matching regex #{@valid_regex}" unless valid
        end
        # added valid_range for numerics 2011-09-29 
        if !in_range?(val)
          raise FieldValidationException, "Field not matching range #{@valid_range}, above #{@above} or below #{@below}  "
        end
      end
      # here is where we should set the forms modified to true - 2009-01
      if modified?
        set_modified true
      end
      # if super fails we would have still set modified to true
      super
      #return valid
    end
1250610
def validate(self, value):
        
        if not self._compiled_regex.match(value):
            raise ValidationError(
                'value {:s} not match r"{:s}"'.format(value, self._regex))
1142854
def validate(self, value, messages=None):
        
        valid     = True
        primitive = value

        def log(msg):
            if messages is not None:
                messages.append(msg)

        if self.enum:
            if value not in self.enum.values():
                valid = False
                flds = (self.name, str(value))
                log("%s value '%s' not in allowed enumerated values." % flds)
            else:
                primitive = int(self.enum.keys()[self.enum.values().index(value)])

        if self.type:
            if self.type.validate(primitive, messages, self.name) is False:
                valid = False

        return valid
165444
def validate(self, value):
        """"""
        if value is not None and not isinstance(value, str):
            raise ValidationError("field must be a string")

        super().validate(value)
357302
public function isValid()
    {
        $value = $this->field->getValue();

        if (is_array($value) || is_object($value)) {
            throw new \Exception("This validator only works on scalar types!");
        }

        // required but not given
        if ($this->required && $value == null) {
            return false;
        } // if the field is not required and the value is empty, then it's also valid
        elseif (!$this->required && $value == "") {
            return true;
        }

        $match = preg_match($this->regex, $value);

        return $this->not ? !$match : $match;
    }
45040
def validate(self, value, param_name, exc=None, logger=None):
        
        if exc is not None:
            self.exc = exc

        if logger is not None:
            self.logger = logger

        if self.type is not None and not type(value) == self.type:  # pylint: disable=unidiomatic-typecheck
            self.error(
                f'invalid type for parameter "{param_name}": {type(value)} (value: {value}) -- expected {self.type}'
            )

        if self.instance is not None and not isinstance(value, self.instance):
            self.error(
                f'invalid instance for parameter "{param_name}": {type(value)} (value: {value})'
                f' -- expected {self.instance}'
            )

        if self.min is not None and value < self.min:
            self.error(f'invalid value for parameter "{param_name}" (under minima of {self.min}): {value}')

        if self.max is not None and value > self.max:
            self.error(f'invalid value for parameter "{param_name}" (over maxima if {self.max}): {value}')

        if self.regex is not None and not re_full_match(self.regex, value):
            self.error(f'invalid value for parameter "{param_name}" (should match: "{self.regex}"): {value}')

        if self.in_list is not None and value not in self.in_list:
            self.error(f'invalid value for parameter "{param_name}"; "{value}" is not in list: {self.in_list}')

        if self.path_exists and not exists(value):
            self.error(f'"{param_name}" file does not exist: {value}')

        return True
397821
function validate(args, required) {
    var result = {
      error: false,
      message: 'No errors'
    }

    // ensure required properties were passed in the arguments hash
    if (required) {
      var keys = _.keys(args);
      required.forEach(function(field) {
        if(!_.contains(keys, field)) {
          result.error = true;
          result.message = 'The following values must be passed: ' + required.join(', ');
        }
      })
    }

    return result;

  }
54713
def valid?(value, negated = false)
      dumped_value = dump(value)

      if required? && dumped_value.nil?
        negated || false
      else
        value_dumped?(dumped_value) || (dumped_value.nil? && (allow_nil? || negated))
      end
    end
323320
def validate_field(field, params)
      begin
        value = params.fetch(field)
        required_error(field) if value.nil? || value.empty?
      rescue KeyError
        required_error(field)
      end
    end
266864
function isValidId(value :any) :boolean {

  return Object.prototype.toString.call(value) === STRING_TAG && value.length > 0;
}
163899
def matches(property_name, regex, *, present_optional=False, message=None):
    """"""
    def check(val):
      """Checks that a value matches a scope-enclosed regex."""
      if not val:
        return present_optional
      else:
        return True if regex.search(val) else False

    return Validation(check, property_name, message)
665384
def validate(path, regex=None):
    
    validated = []
    for elem in path:
        key = elem[0]
        strkey = str(key)
        if (regex and (not regex.findall(strkey))):
            raise dpath.exceptions.InvalidKeyName("{} at {} does not match the expression {}"
                                                  "".format(strkey,
                                                            validated,
                                                            regex.pattern))
        validated.append(strkey)
503646
function (value) {
            if (value == null) {
                value = this._getText();
            }

            // _getText only handles valid / invalid values and prefills, not the helptext
            if (!value && !this._isPassword) {
                // We don't want to handle helptext in password fields, first remove any text
                this.getTextInputField().value = "";
                this.setHelpText(true);
            } else if (value) {
                this.setHelpText(false);
                this.getTextInputField().value = value;
            }
        }
821494
def Validate(self, value, **_):
    """"""
    # None is a valid value - it means the field is not set.
    if value is None:
      return

    # If the value is a string we need to try to convert it to an integer.
    checked_value = value
    if isinstance(value, string_types):
      # NOTE: that when initializing from string, enum values are
      # case-insensitive.
      checked_value = self.enum.get(value.upper())
      if checked_value is None and value.isdigit():
        checked_value = int(value)
      if checked_value is None:
        raise type_info.TypeValueError(
            "Value %s is not a valid enum value for field %s" %
            (value, self.name))

    return EnumNamedValue(checked_value, name=self.reverse_enum.get(value))
543005
def _in(field, filter_value):
        
        valid = False
        if field in filter_value:
            valid = True
        return valid
495412
def validate(value):
        
        if not helpers.has_len(value):
            return False

        return COUNTRIES.has_key(str(value).lower())
946798
def accepts(regex, negate, *values):
    
    return any(v and regex.search(v) for v in values) != negate