http://jqueryvalidation.org/required-method/
962997
function( value, element, param ) {
			// check if dependency is met
			if ( !this.depend(param, element) ) {
				return "dependency-mismatch";
			}
			if ( element.nodeName.toLowerCase() === "select" ) {
				// could be an array for select-multiple or a string, both are fine this way
				var val = $(element).val();
				return val && val.length > 0;
			}
			if ( this.checkable(element) ) {
				return this.getLength(value, element) > 0;
			}
			return $.trim(value).length > 0;
		}
893498
function error( message, errors ) {
      const trim = _ => _.replace( /^\s+/, '' ).replace( /\s+$/, '' );
      const ajvMessage = ajv.errorsText( errors, { dataVar: '' } );
      const error = new Error(
         `${message}: ${trim(ajvMessage)} ${JSON.stringify(errors.map(e => e.params))}`
      );
      error.name = 'ValidationError';
      error.errors = errors;
      return error;
   }
84060
function submitSearch() {
    var searchInput = getSearchInput();
    // FIXME: SUI validation for select2 field
      if (!searchInput.valid) {
      alert('Please select team members');
      return;
    }
    console.log('publishing', searchInput);
    $('.search.message').html('Search results:');
    $('.search.message').removeClass('hidden');
    context.pubsub.status('queued', function(res) {
      console.log(res);
      var message = '';
      if (res.err) {
        message = res.err;
      } else {
        message = 'found <a target="_searchresult" href="' + res.status.uri + '">' + res.status.uri + '</a> from ' + res.status.source;
      }

      $('.search.message').append('<div>' + message + '</div>');
    });

    context.pubsub.search.queue(searchInput);
    context.queryLib.setAnnotationTags($('#searchCategories').val().split(','));
    context.queryLib.submitQuery();
  }
792313
protected void validateRequired(int index, String errorKey, String errorMessage) {
		String value = controller.getPara(index);
		if (value == null /* || "".equals(value) */) {
			addError(errorKey, errorMessage);
		}
	}
784565
function defaultOnInputValidationResult(el, validationsResult, validatorName, stateEnum) {

        var errorDiv;

        // for radio buttons and checkboxes:  get the last element in group by name
        if ((el.nodeName.toLowerCase() === 'input' && (el.type === 'radio' || el.type === 'checkbox'))) {

            var getAllByName = el.parentNode.querySelectorAll('input[name="' + el.name + '"]');

            el = getAllByName.item(getAllByName.length - 1);
        }

        if (validationsResult.stateEnum === stateEnum.invalid) {

            errorDiv = getExistingErrorDiv(el);
            if (errorDiv) {
                errorDiv.textContent = validationsResult.message;
            } else {
                appendNewErrorDiv(el, validationsResult.message);
            }

            el.style.borderStyle = "solid";
            el.style.borderColor = "#ff0000";
            $$.addClass(el, "vivalid-error-input");
        } else {
            errorDiv = getExistingErrorDiv(el);
            if (errorDiv) {
                errorDiv.parentNode.removeChild(errorDiv);
                el.style.borderStyle = "";
                el.style.borderColor = "";
                $$.removeClass(el, "vivalid-error-input");
            }
        }

        function getExistingErrorDiv(el) {
            if (el.nextElementSibling && el.nextElementSibling.className === "vivalid-error") {
                return el.nextElementSibling;
            }

        }

        function appendNewErrorDiv(el, message) {
            errorDiv = document.createElement("DIV");
            errorDiv.className = "vivalid-error";
            errorDiv.style.color = "#ff0000";
            var t = document.createTextNode(validationsResult.message);
            errorDiv.appendChild(t);
            el.parentNode.insertBefore(errorDiv, el.nextElementSibling);
        }

    }
762351
function () {
/*Line 112 - 'AtomFormField.js' */                this._validate = true;
/*Line 113 - 'AtomFormField.js' */                if (!(this._required || this._regex || this._dataType))
/*Line 114 - 'AtomFormField.js' */                    return this._isValid === undefined ? true : this._isValid;



/*Line 118 - 'AtomFormField.js' */                if (this._isValid) {
/*Line 119 - 'AtomFormField.js' */                    AtomBinder.setValue(this, "error", "");
/*Line 120 - 'AtomFormField.js' */                    if (this._isValidSet) {
/*Line 121 - 'AtomFormField.js' */                        return true;
/*Line 122 - 'AtomFormField.js' */                    }
/*Line 123 - 'AtomFormField.js' */                }

/*Line 125 - 'AtomFormField.js' */                this._isValid = true;

/*Line 127 - 'AtomFormField.js' */                if (this._fieldValue !== undefined) {
/*Line 128 - 'AtomFormField.js' */                    this.validateValue(this._fieldValue);
/*Line 129 - 'AtomFormField.js' */                } else {
/*Line 130 - 'AtomFormField.js' */                    // check validity..
/*Line 131 - 'AtomFormField.js' */                    this.validateChildren(this._element);
/*Line 132 - 'AtomFormField.js' */                }
/*Line 133 - 'AtomFormField.js' */                if (this._isValid) {
/*Line 134 - 'AtomFormField.js' */                    AtomBinder.setValue(this, "error", "");
/*Line 135 - 'AtomFormField.js' */                }
/*Line 136 - 'AtomFormField.js' */                return this._isValid;
/*Line 137 - 'AtomFormField.js' */            }
517273
function validate(res, result) {
  if (!result) return true;

  var err = new Error('Validation failed');
  try {
    err.errors = result.errors();
  } catch (err) {
    err.errors = [result.validation];
  }
  err.expose = true;
  err.statusCode = 400;
  err.toJSON = function() {
    return {
      message: this.message,
      errors: this.errors,
    };
  };

  res.sf.reply(err);
}
845452
function makeError(id, msg, err, requireModules) {
      var e = new Error(msg + "\nhttp://requirejs.org/docs/errors.html#" + id);
      e.requireType = id;
      e.requireModules = requireModules;
      if (err) {
        e.originalError = err;
      }
      return e;
    }
792840
function required (val, arg) {
  var isRequired = arg === undefined ? true : arg;
  if (Array.isArray(val)) {
    if (val.length !== 0) {
      var valid = true;
      for (var i = 0, l = val.length; i < l; i++) {
        valid = required(val[i], isRequired);
        if ((isRequired && !valid) || (!isRequired && valid)) {
          break
        }
      }
      return valid
    } else {
      return !isRequired
    }
  } else if (typeof val === 'number' || typeof val === 'function') {
    return isRequired
  } else if (typeof val === 'boolean') {
    return val === isRequired
  } else if (typeof val === 'string') {
    return isRequired ? (val.length > 0) : (val.length <= 0)
  } else if (val !== null && typeof val === 'object') {
    return isRequired ? (Object.keys(val).length > 0) : (Object.keys(val).length <= 0)
  } else if (val === null || val === undefined) {
    return !isRequired
  } else {
    return !isRequired
  }
}
241919
function() {
		if ( $(this[0]).is("form")) {
			return this.validate().form();
		} else {
			var valid = true;
			var validator = $(this[0].form).validate();
			this.each(function() {
				valid = valid && validator.element(this);
			});
			return valid;
		}
	}
191549
function(e) {
    var error_free, form, isFileUpload, l, len, len1, len2, m, map, n, o, opts, ref1, ref2, ref3, val;
    if (e !== null) {
      e.preventDefault();
    }
    form = $('.sandbox', $(this.el));
    error_free = true;
    form.find('input.required').each(function() {
      $(this).removeClass('error');
      if (jQuery.trim($(this).val()) === '') {
        $(this).addClass('error');
        $(this).wiggle({
          callback: (function(_this) {
            return function() {
              $(_this).focus();
            };
          })(this)
        });
        error_free = false;
      }
    });
    form.find('textarea.required').each(function() {
      $(this).removeClass('error');
      if (jQuery.trim($(this).val()) === '') {
        $(this).addClass('error');
        $(this).wiggle({
          callback: (function(_this) {
            return function() {
              return $(_this).focus();
            };
          })(this)
        });
        error_free = false;
      }
    });
    if (error_free) {
      map = {};
      opts = {
        parent: this
      };
      isFileUpload = false;
      ref1 = form.find('input');
      for (l = 0, len = ref1.length; l < len; l++) {
        o = ref1[l];
        if ((o.value !== null) && jQuery.trim(o.value).length > 0) {
          map[o.name] = o.value;
        }
        if (o.type === 'file') {
          map[o.name] = o.files[0];
          isFileUpload = true;
        }
      }
      ref2 = form.find('textarea');
      for (m = 0, len1 = ref2.length; m < len1; m++) {
        o = ref2[m];
        if ((o.value !== null) && jQuery.trim(o.value).length > 0) {
          map[o.name] = o.value;
        }
      }
      ref3 = form.find('select');
      for (n = 0, len2 = ref3.length; n < len2; n++) {
        o = ref3[n];
        val = this.getSelectedValue(o);
        if ((val !== null) && jQuery.trim(val).length > 0) {
          map[o.name] = val;
        }
      }
      opts.responseContentType = $('div select[name=responseContentType]', $(this.el)).val();
      opts.requestContentType = $('div select[name=parameterContentType]', $(this.el)).val();
      $('.response_throbber', $(this.el)).show();
      if (isFileUpload) {
        return this.handleFileUpload(map, form);
      } else {
        return this.model['do'](map, opts, this.showCompleteStatus, this.showErrorStatus, this);
      }
    }
  }
650095
public function jQueryValidationEngine($html)
	{
		$validation = array();
		if($this->required===true)
		{
			$validation[] = 'required';
		}
		if(!empty($validation))
			$html = str_replace("\" class=\"", "\" class=\"validate[".implode(',', $validation)."] ", $html);
		return $html;
	}
893174
function (validation) {

            validation = validation.toString().replace(/\s/g, '');

            if (validation.charAt(0) === "[" && validation.charAt(validation.length - 1) === "]") {
                validation = validation.replace(/^\[|]$/g, '');
            }

            return validation;

        }
851118
public function validate ($validate_rule = null, $data_set = [], $force_source = false) {
		//結果の初期化
		$result = [];

		//現在のバリデーションルールを取得
		$validate_rule = $validate_rule ?? $this->rule->validate ?? null;
		if (is_callable($validate_rule)) {
			$validate_rule = $validate_rule();
		}

		//実行対象のバリデーションがあるか確認、なければ対象はなかったとして終了
		if (is_null($validate_rule)) {
			$this->hasValidator = false;
			return [];
		}
		$this->hasValidator = true;

		//外部入力値を取得
		$request_access = LazyArrayObject::Create([
			'parameter'	=> Request::GetParameters(),
			'data'		=> Request::GetPostData(),
			'post'		=> Request::GetPost(),
			'upload'	=> Request::GetUploadFileData(),
			'cookie'	=> Request::GetCookies(),
			'route'		=> $this->route,
			'direct'	=> $data_set,
		]);

		//検証の実行：入力一要素ごとに処理を行う
		foreach (array_filter(($validate_rule instanceof \ArrayObject) ? $validate_rule->getArrayCopy() : $validate_rule) as $target => $rules) {
			//短縮設定を掬い取る
			$rule_length = count($rules);
			for ($i = 0;$i < $rule_length;$i++) {
				$data_set = array_slice($rules, $i, 1);
				$idx = key($data_set);
				$rule = current($data_set);
				if (is_int($idx) && is_string($rule)) {
					$rules = array_merge(array_slice($rules, 0, $i), [$rule => true], array_slice($rules, $i + 1));
				}
			}

			//先行する検証の結果を参照するかどうか
			$premise = $rules['premise'] ?? null;
			if ($premise) {
				foreach (Arrays::AdjustArray($premise) as $error_name) {
					//一つでもエラーとなっている先行検証結果がある場合、処理そのものをスキップ
					if (isset($result[$error_name])) {
						continue 2;
					}
				}
			}

			//データ取得対象ソースの指定
			$source = $force_source ?: ($rules['rules']['source'] ?? $rules['source'] ?? (Request::IsPostMethod() ? 'data' : 'parameter'));
			$data = $request_access->$source;

			//先行確認値があった場合、突合チェック
			$pre_check_pattern = null;
			if (($position = strpos($target, '@value=')) !== false) {
				$pre_check_pattern = substr($target, $position + strlen('@value='));
				$target = substr($target, 0, $position);

				//先行入力値とマッチしなかった場合はスキップ
				if ($pre_check_pattern !== null && preg_match(sprintf("/^%s$/u", str_replace('/', "\\/", $pre_check_pattern)), $data->$target) !== 1) {
					continue;
				}
			}

			//指定があった場合、値の取得先を差し替え
			$name = $rules['name'] ?? $target;

			//検証実行：結果はどんどん末尾に追加していく
			$ret = Validator::BulkCheck($data, [$name => $rules], $result) ?? [];
			if (!empty($ret)) {
				foreach ($ret as $target => $error_message_list) {
					$result += $result + [$target => $error_message_list];
				}

				//入力要素レベルのis_lastが存在した場合、ここで処理終了となる
				if ($rules['is_last'] ?? null) {
					break;
				}
			}
		}

		//処理の終了
		return $result;
	}
1148820
function validateIsRequired()
    {
        $classAttribute = $this->contentClassAttribute();
        $validationParameters = $this->validationParameters();
        if ( !( isset( $validationParameters['skip-isRequired'] ) && $validationParameters['skip-isRequired'] === true ) && $classAttribute->attribute( "is_required" ) )
            return true;

        return false;
    }
625460
function validate(extension, name) {
  'use strict';

  var errMsg = (name) ? 'Error in ' + name + ' extension->' : 'Error in unnamed extension',
    ret = {
      valid: true,
      error: ''
    };

  if (!showdown.helper.isArray(extension)) {
    extension = [extension];
  }

  for (var i = 0; i < extension.length; ++i) {
    var baseMsg = errMsg + ' sub-extension ' + i + ': ',
        ext = extension[i];
    if (typeof ext !== 'object') {
      ret.valid = false;
      ret.error = baseMsg + 'must be an object, but ' + typeof ext + ' given';
      return ret;
    }

    if (!showdown.helper.isString(ext.type)) {
      ret.valid = false;
      ret.error = baseMsg + 'property "type" must be a string, but ' + typeof ext.type + ' given';
      return ret;
    }

    var type = ext.type = ext.type.toLowerCase();

    // normalize extension type
    if (type === 'language') {
      type = ext.type = 'lang';
    }

    if (type === 'html') {
      type = ext.type = 'output';
    }

    if (type !== 'lang' && type !== 'output' && type !== 'listener') {
      ret.valid = false;
      ret.error = baseMsg + 'type ' + type + ' is not recognized. Valid values: "lang/language", "output/html" or "listener"';
      return ret;
    }

    if (type === 'listener') {
      if (showdown.helper.isUndefined(ext.listeners)) {
        ret.valid = false;
        ret.error = baseMsg + '. Extensions of type "listener" must have a property called "listeners"';
        return ret;
      }
    } else {
      if (showdown.helper.isUndefined(ext.filter) && showdown.helper.isUndefined(ext.regex)) {
        ret.valid = false;
        ret.error = baseMsg + type + ' extensions must define either a "regex" property or a "filter" method';
        return ret;
      }
    }

    if (ext.listeners) {
      if (typeof ext.listeners !== 'object') {
        ret.valid = false;
        ret.error = baseMsg + '"listeners" property must be an object but ' + typeof ext.listeners + ' given';
        return ret;
      }
      for (var ln in ext.listeners) {
        if (ext.listeners.hasOwnProperty(ln)) {
          if (typeof ext.listeners[ln] !== 'function') {
            ret.valid = false;
            ret.error = baseMsg + '"listeners" property must be an hash of [event name]: [callback]. listeners.' + ln +
              ' must be a function but ' + typeof ext.listeners[ln] + ' given';
            return ret;
          }
        }
      }
    }

    if (ext.filter) {
      if (typeof ext.filter !== 'function') {
        ret.valid = false;
        ret.error = baseMsg + '"filter" must be a function, but ' + typeof ext.filter + ' given';
        return ret;
      }
    } else if (ext.regex) {
      if (showdown.helper.isString(ext.regex)) {
        ext.regex = new RegExp(ext.regex, 'g');
      }
      if (!ext.regex instanceof RegExp) {
        ret.valid = false;
        ret.error = baseMsg + '"regex" property must either be a string or a RegExp object, but ' + typeof ext.regex + ' given';
        return ret;
      }
      if (showdown.helper.isUndefined(ext.replace)) {
        ret.valid = false;
        ret.error = baseMsg + '"regex" extensions must implement a replace string or function';
        return ret;
      }
    }
  }
  return ret;
}
1359194
function ValidationFailed(reason) {
  Error.captureStackTrace(this, this.constructor);
  this.type = 'bad_request';
  this.statusCode = 400;
  this.message = 'Request validation failed';
  this.reason = reason;
}