Create 2 default validations rules for each output variable.

        * One validation rule to check that the output variable is not null.
        * One validation rule to ensure the output value is of the correct type.
777940
def profile_settings_validations(self):
        

        ij = self.load_install_json(self.args.ij)
        validations = {'rules': [], 'outputs': []}

        job_id = randint(1000, 9999)
        output_variables = ij.get('playbook', {}).get('outputVariables') or []
        if self.args.permutation_id is not None:
            output_variables = self._output_permutations[self.args.permutation_id]
        # for o in ij.get('playbook', {}).get('outputVariables') or []:
        for o in output_variables:
            variable = '#App:{}:{}!{}'.format(job_id, o.get('name'), o.get('type'))
            validations['outputs'].append(variable)

            # null check
            od = OrderedDict()
            if o.get('type').endswith('Array'):
                od['data'] = [None, []]
                od['data_type'] = 'redis'
                od['operator'] = 'ni'
            else:
                od['data'] = None
                od['data_type'] = 'redis'
                od['operator'] = 'ne'
            od['variable'] = variable
            validations['rules'].append(od)

            # type check
            od = OrderedDict()
            if o.get('type').endswith('Array'):
                od['data'] = 'array'
                od['data_type'] = 'redis'
                od['operator'] = 'it'
            elif o.get('type').endswith('Binary'):
                od['data'] = 'binary'
                od['data_type'] = 'redis'
                od['operator'] = 'it'
            elif o.get('type').endswith('Entity') or o.get('type') == 'KeyValue':
                od['data'] = 'entity'
                od['data_type'] = 'redis'
                od['operator'] = 'it'
            else:
                od['data'] = 'string'
                od['data_type'] = 'redis'
                od['operator'] = 'it'
            od['variable'] = variable
            validations['rules'].append(od)
        return validations
1195519
function validate(inputs, options) {
    let hasError = false

    if (inputs.length >= 2) {
        console.error("ERROR: the input file should not be multiple.")
        hasError = true
    }
    if (inputs.length >= 1 && !fs.existsSync(inputs[0])) {
        console.error("ERROR: the input file should exist.")
        hasError = true
    }
    if (options.output != null && Array.isArray(options.output)) {
        console.error("ERROR: --output option should not be multiple.")
        hasError = true
    }
    if (inputs.length >= 1 && options.output != null && path.resolve(inputs[0]) === path.resolve(options.output)) {
        console.error("ERROR: --output option should not be the same as the input file.")
        hasError = true
    }
    if (options.manifest != null && Array.isArray(options.manifest)) {
        console.error("ERROR: --manifest option should not be multiple.")
        hasError = true
    }

    return !hasError
}
1355657
def RunValidationOutputFromOptions(feed, options):
  """"""
  if options.output.upper() == "CONSOLE":
    return RunValidationOutputToConsole(feed, options)
  else:
    return RunValidationOutputToFilename(feed, options, options.output)
1211135
void setOutputVarInited() {
    outputVars.pop();
    outputVars.push(OutputVar.create(currOutputVarName, true));
    currOutputVarIsInited = true;
  }
1342101
function validate(validator, check, signal) {
	for (var propName in signal) {
		var property = signal[propName];
		var validate = validator[propName];
		if(typeof validate === 'function') {
			var res = validate(property, signal);	
			check(res.msg, res.result);
		}
	}
}
1033263
def validations
      name = @name
      @klass.send(:validates_each, name) do |record, attr, value|
        record.send(name).errors.each do |error|
          record.errors.add(name, error)
        end
      end
    end
240201
protected function defaultVariables()
    {
        $this->canvas  = NULL;
        $this->save    = NULL;
        $this->output  = true;
        $this->quality = NULL;
    }
984587
function validation() {
  const target = this._obj;
  this.assert(_.isObject(target), '#{this} is not a Joi validation because it must be an object');
  this.assert(!_.isEmpty(target), '#{this} is not a Joi validation because it is an empty object');
  const fields = _.keys(target);
  const allFieldsPresent = _.every(FIELDS_TO_VALIDATE.map(field => _.includes(fields, field)));

  this.assert(
    allFieldsPresent,
    `${this} is not a validation because it does not contain expected keys`
  );
}
370656
function processRule(rule) {
    if (typeof rule !== 'function' && typeof rule !== 'string') {
        OBLIGATIONS.precondition(Array.isArray(rule) && rule[0] || rule.name, 'Validator name must be specified.');
    }
    var __result;
    main: {
        if (typeof rule === 'string') {
            __result = exports.create(rule);
            break main;
        } else if (typeof rule === 'function') {
            __result = new exports.Validator({ validate: rule });
            break main;
        } else if (Array.isArray(rule)) {
            __result = exports.create.apply(exports, rule);
            break main;
        } else {
            __result = exports.create(rule.name, rule);
            break main;
        }
    }
    OBLIGATIONS.postcondition(__result instanceof exports.Validator);
    return __result;
}
558202
protected function setupValidations()
    {
        $this->validations->of(
            TransactionType::CAPTURE |
            TransactionType::EDIT |
            TransactionType::HOLD |
            TransactionType::RELEASE
        )
            ->check('transactionId')->isNotNull();

        $this->validations->of(TransactionType::EDIT)
            ->with(TransactionModifier::LEVEL_II)
            ->check('taxType')->isNotNull();

        $this->validations->of(TransactionType::REFUND)
            ->when('amount')->isNotNull()
            ->check('currency')->isNotNull();

        $this->validations->of(TransactionType::VERIFY_SIGNATURE)
            ->check('payerAuthenticationResponse')->isNotNull()
            ->check('amount')->isNotNull()
            ->check('currency')->isNotNull()
            ->check('orderId')->isNotNull();
    }
191118
function optimizeRule( rule ) {
		var validatorName,
			requiredProperties,
			i;

		for ( validatorName in validators )
			rule[ validatorName ] = validatorFunction( rule[ validatorName ] );

		var nothingRequired = true;
		for ( i in validatorsRequired ) {
			validatorName = validatorsRequired[ i ];
			requiredProperties = optimizeRequiredProperties( rule[ validatorName ] );
			// Don't set anything if there are no required properties. This will allow to
			// save some memory by GCing all empty arrays (requiredProperties).
			if ( requiredProperties.length ) {
				rule[ validatorName ] = requiredProperties;
				nothingRequired = false;
			}
		}

		rule.nothingRequired = nothingRequired;
		rule.noProperties = !( rule.attributes || rule.classes || rule.styles );
	}
519431
protected function make_fields_validation() {
		foreach ( $this->fields as $key => $field ) {
			if ( $this->maybe_skip_field( $field ) ) {
				continue;
			}

			if ( $rules = $field->get_option( 'validate' ) ) {
				$attributes = ( new Rules_Parser( $field ) )->parse( $rules );
				$field->set_attribute( $attributes );
			}
		}
	}
1265250
private void validateCoefficients() {
        if (coefsValid)
            return;

        if (n >= 2) {
            double xBar = (double) sumX / n;
            double yBar = (double) sumY / n;

            a1 = (double) ((n * sumXY - sumX * sumY) / (n * sumXX - sumX * sumX));
            a0 = (double) (yBar - a1 * xBar);
        } else {
            a0 = a1 = Double.NaN;
        }

        coefsValid = true;
    }
1280795
function BusinessRules(Data) {
            this.Data = Data;
            this.InvoiceValidator = this.createInvoiceValidator().CreateRule("Data");

            this.ValidationResult = this.InvoiceValidator.ValidationResult;
        }
433602
def validate(context_name = default_validation_context)
      errors.clear
      validation_violations(context_name).each { |v| errors.add(v) }

      self
    end
727267
function validate(values) {
    var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
    var s = this;

    var _tv4$validateMultiple = tv4.validateMultiple(values, s),
        valid = _tv4$validateMultiple.valid,
        errors = _tv4$validateMultiple.errors;

    if (valid) {
      return null;
    }

    var assign = options.assign,
        _options$name = options.name,
        name = _options$name === void 0 ? 'SchemaError' : _options$name;
    var _s$schema = s.schema,
        schema = _s$schema === void 0 ? {} : _s$schema;
    var error = new Error("Validation failed with schema: ".concat(schema.title || schema.id || schema.description));
    return Object.assign(error, {
      id: uuid.v4(),
      name: name,
      errors: errors,
      schema: schema,
      values: values,
      engine: 'tv4'
    }, assign);
  }
1193584
function addValidElements(validElements) {
        var ei, el, ai, al, matches, element, attr, attrData, elementName, attrName, attrType, attributes, attributesOrder,
          prefix, outputName, globalAttributes, globalAttributesOrder, key, value,
          elementRuleRegExp = /^([#+\-])?([^\[!\/]+)(?:\/([^\[!]+))?(?:(!?)\[([^\]]+)\])?$/,
          attrRuleRegExp = /^([!\-])?(\w+::\w+|[^=:<]+)?(?:([=:<])(.*))?$/,
          hasPatternsRegExp = /[*?+]/;

        if (validElements) {
          // Split valid elements into an array with rules
          validElements = split(validElements, ',');

          if (elements['@']) {
            globalAttributes = elements['@'].attributes;
            globalAttributesOrder = elements['@'].attributesOrder;
          }

          // Loop all rules
          for (ei = 0, el = validElements.length; ei < el; ei++) {
            // Parse element rule
            matches = elementRuleRegExp.exec(validElements[ei]);
            if (matches) {
              // Setup local names for matches
              prefix = matches[1];
              elementName = matches[2];
              outputName = matches[3];
              attrData = matches[5];

              // Create new attributes and attributesOrder
              attributes = {};
              attributesOrder = [];

              // Create the new element
              element = {
                attributes: attributes,
                attributesOrder: attributesOrder
              };

              // Padd empty elements prefix
              if (prefix === '#') {
                element.paddEmpty = true;
              }

              // Remove empty elements prefix
              if (prefix === '-') {
                element.removeEmpty = true;
              }

              if (matches[4] === '!') {
                element.removeEmptyAttrs = true;
              }

              // Copy attributes from global rule into current rule
              if (globalAttributes) {
                for (key in globalAttributes) {
                  attributes[key] = globalAttributes[key];
                }

                attributesOrder.push.apply(attributesOrder, globalAttributesOrder);
              }

              // Attributes defined
              if (attrData) {
                attrData = split(attrData, '|');
                for (ai = 0, al = attrData.length; ai < al; ai++) {
                  matches = attrRuleRegExp.exec(attrData[ai]);
                  if (matches) {
                    attr = {};
                    attrType = matches[1];
                    attrName = matches[2].replace(/::/g, ':');
                    prefix = matches[3];
                    value = matches[4];

                    // Required
                    if (attrType === '!') {
                      element.attributesRequired = element.attributesRequired || [];
                      element.attributesRequired.push(attrName);
                      attr.required = true;
                    }

                    // Denied from global
                    if (attrType === '-') {
                      delete attributes[attrName];
                      attributesOrder.splice(inArray(attributesOrder, attrName), 1);
                      continue;
                    }

                    // Default value
                    if (prefix) {
                      // Default value
                      if (prefix === '=') {
                        element.attributesDefault = element.attributesDefault || [];
                        element.attributesDefault.push({ name: attrName, value: value });
                        attr.defaultValue = value;
                      }

                      // Forced value
                      if (prefix === ':') {
                        element.attributesForced = element.attributesForced || [];
                        element.attributesForced.push({ name: attrName, value: value });
                        attr.forcedValue = value;
                      }

                      // Required values
                      if (prefix === '<') {
                        attr.validValues = makeMap(value, '?');
                      }
                    }

                    // Check for attribute patterns
                    if (hasPatternsRegExp.test(attrName)) {
                      element.attributePatterns = element.attributePatterns || [];
                      attr.pattern = patternToRegExp(attrName);
                      element.attributePatterns.push(attr);
                    } else {
                      // Add attribute to order list if it doesn't already exist
                      if (!attributes[attrName]) {
                        attributesOrder.push(attrName);
                      }

                      attributes[attrName] = attr;
                    }
                  }
                }
              }

              // Global rule, store away these for later usage
              if (!globalAttributes && elementName == '@') {
                globalAttributes = attributes;
                globalAttributesOrder = attributesOrder;
              }

              // Handle substitute elements such as b/strong
              if (outputName) {
                element.outputName = elementName;
                elements[outputName] = element;
              }

              // Add pattern or exact element
              if (hasPatternsRegExp.test(elementName)) {
                element.pattern = patternToRegExp(elementName);
                patternElements.push(element);
              } else {
                elements[elementName] = element;
              }
            }
          }
        }
      }