Validation stamp access
337073
@RequestMapping(value = "entity/validationStamp/{project}/{branch}/{validationStamp:.*}", method = RequestMethod.GET)
    public ValidationStamp validationStamp(@PathVariable String project, @PathVariable String branch, @PathVariable String validationStamp) {
        return structureService.findValidationStampByName(project, branch, validationStamp)
                .orElseThrow(() -> new ValidationStampNotFoundException(project, branch, validationStamp));
    }
694094
function validation($data, $files) {
        global $COURSE, $DB, $CFG;
        $errors = parent::validation($data, $files);

        $mform =& $this->_form;

        $errors = array();

        if ($mform->elementExists('name')) {
            $name = trim($data['name']);
            if ($name == '') {
                $errors['name'] = get_string('required');
            }
        }

        $grade_item = grade_item::fetch(array('itemtype'=>'mod', 'itemmodule'=>$data['modulename'],
                     'iteminstance'=>$data['instance'], 'itemnumber'=>0, 'courseid'=>$COURSE->id));
        if ($data['coursemodule']) {
            $cm = $DB->get_record('course_modules', array('id'=>$data['coursemodule']));
        } else {
            $cm = null;
        }

        if ($mform->elementExists('cmidnumber')) {
            // verify the idnumber
            if (!grade_verify_idnumber($data['cmidnumber'], $COURSE->id, $grade_item, $cm)) {
                $errors['cmidnumber'] = get_string('idnumbertaken');
            }
        }

        // Ratings: Don't let them select an aggregate type without selecting a scale.
        // If the user has selected to use ratings but has not chosen a scale or set max points then the form is
        // invalid. If ratings have been selected then the user must select either a scale or max points.
        // This matches (horrible) logic in data_preprocessing.
        if (isset($data['assessed']) && $data['assessed'] > 0 && empty($data['scale'])) {
            $errors['assessed'] = get_string('scaleselectionrequired', 'rating');
        }

        // Check that the grade pass is a valid number.
        $gradepassvalid = false;
        if (isset($data['gradepass'])) {
            if (unformat_float($data['gradepass'], true) === false) {
                $errors['gradepass'] = get_string('err_numeric', 'form');
            } else {
                $gradepassvalid = true;
            }
        }

        // Grade to pass: ensure that the grade to pass is valid for points and scales.
        // If we are working with a scale, convert into a positive number for validation.
        if ($gradepassvalid && isset($data['gradepass']) && (!empty($data['grade']) || !empty($data['scale']))) {
            $scale = !empty($data['grade']) ? $data['grade'] : $data['scale'];
            if ($scale < 0) {
                $scalevalues = $DB->get_record('scale', array('id' => -$scale));
                $grade = count(explode(',', $scalevalues->scale));
            } else {
                $grade = $scale;
            }
            if (unformat_float($data['gradepass']) > $grade) {
                $errors['gradepass'] = get_string('gradepassgreaterthangrade', 'grades', $grade);
            }
        }

        // Completion: Don't let them choose automatic completion without turning
        // on some conditions. Ignore this check when completion settings are
        // locked, as the options are then disabled.
        if (array_key_exists('completion', $data) &&
                $data['completion'] == COMPLETION_TRACKING_AUTOMATIC &&
                !empty($data['completionunlocked'])) {
            if (empty($data['completionview']) && empty($data['completionusegrade']) &&
                !$this->completion_rule_enabled($data)) {
                $errors['completion'] = get_string('badautocompletion', 'completion');
            }
        }

        // Availability: Check availability field does not have errors.
        if (!empty($CFG->enableavailability)) {
            \core_availability\frontend::report_validation_errors($data, $errors);
        }

        $pluginerrors = $this->plugin_extend_coursemodule_validation($data);
        if (!empty($pluginerrors)) {
            $errors = array_merge($errors, $pluginerrors);
        }

        return $errors;
    }
879260
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(isset($_FILES[$key])) {
            if(!\file_exists($_FILES[$key]['tmp_name'])) {
                return 'formvalidator_make_invalid_file';
            }
            
            $size = \getimagesize($_FILES[$key]['tmp_name']);
        } else {
            if(!$exists) {
                return false;
            }
            
            $size = @\getimagesizefromstring($value);
        }
        
        if(!$size) {
            return 'formvalidator_make_invalid_file';
        }
        
        $n = \explode(',', $options);
        foreach($n as $x) {
            $k = \explode('=', $x);
            switch($k[0]) {
                case 'min_width': // @codeCoverageIgnore
                    if($k[1] > $size[0]) {
                        return array('formvalidator_make_min_width', array('{0}' => $options));
                    }
                break;
                case 'min_height': // @codeCoverageIgnore
                    if($k[1] > $size[1]) {
                        return array('formvalidator_make_min_height', array('{0}' => $options));
                    }
                break;
                case 'width': // @codeCoverageIgnore
                    if($k[1] != $size[0]) {
                        return array('formvalidator_make_width', array('{0}' => $options));
                    }
                break;
                case 'height': // @codeCoverageIgnore
                    if($k[1] != $size[1]) {
                        return array('formvalidator_make_height', array('{0}' => $options));
                    }
                break;
                case 'max_width': // @codeCoverageIgnore
                    if($k[1] < $size[0]) {
                        return array('formvalidator_make_max_width', array('{0}' => $options));
                    }
                break;
                case 'max_height': // @codeCoverageIgnore
                    if($k[1] < $size[1]) {
                        return array('formvalidator_make_max_height', array('{0}' => $options));
                    }
                break;
                case 'ratio': // @codeCoverageIgnore
                    if(\mb_strpos($k[1], '/') !== false) {
                        $k[1] = \explode('/', $k[1]);
                        $k[1] = $k[1][0] / $k[1][1];
                    }
                    
                    if(\number_format(($size[0] / $size[1]), 1) != \number_format($k[1], 1)) {
                        return array('formvalidator_make_ratio', array('{0}' => $options));
                    }
                break;
            }
        }
        
        return true;
    }
675817
function validateRSAA(action) {
  var validationErrors = [];
  const validCallAPIKeys = [
    'endpoint',
    'options',
    'method',
    'body',
    'headers',
    'credentials',
    'bailout',
    'types',
    'fetch',
    'ok'
  ];
  const validMethods = [
    'GET',
    'HEAD',
    'POST',
    'PUT',
    'PATCH',
    'DELETE',
    'OPTIONS'
  ];
  const validCredentials = ['omit', 'same-origin', 'include'];

  if (!isRSAA(action)) {
    validationErrors.push(
      'RSAAs must be plain JavaScript objects with an [RSAA] property'
    );
    return validationErrors;
  }

  const callAPI = action[RSAA];
  if (!isPlainObject(callAPI)) {
    validationErrors.push('[RSAA] property must be a plain JavaScript object');
  }
  for (let key in callAPI) {
    if (!~validCallAPIKeys.indexOf(key)) {
      validationErrors.push(`Invalid [RSAA] key: ${key}`);
    }
  }

  const {
    endpoint,
    method,
    headers,
    options,
    credentials,
    types,
    bailout,
    fetch,
    ok
  } = callAPI;
  if (typeof endpoint === 'undefined') {
    validationErrors.push('[RSAA] must have an endpoint property');
  } else if (typeof endpoint !== 'string' && typeof endpoint !== 'function') {
    validationErrors.push(
      '[RSAA].endpoint property must be a string or a function'
    );
  }
  if (typeof method === 'undefined') {
    validationErrors.push('[RSAA] must have a method property');
  } else if (typeof method !== 'string') {
    validationErrors.push('[RSAA].method property must be a string');
  } else if (!~validMethods.indexOf(method.toUpperCase())) {
    validationErrors.push(`Invalid [RSAA].method: ${method.toUpperCase()}`);
  }

  if (
    typeof headers !== 'undefined' &&
    !isPlainObject(headers) &&
    typeof headers !== 'function'
  ) {
    validationErrors.push(
      '[RSAA].headers property must be undefined, a plain JavaScript object, or a function'
    );
  }
  if (
    typeof options !== 'undefined' &&
    !isPlainObject(options) &&
    typeof options !== 'function'
  ) {
    validationErrors.push(
      '[RSAA].options property must be undefined, a plain JavaScript object, or a function'
    );
  }
  if (typeof credentials !== 'undefined') {
    if (typeof credentials !== 'string') {
      validationErrors.push(
        '[RSAA].credentials property must be undefined, or a string'
      );
    } else if (!~validCredentials.indexOf(credentials)) {
      validationErrors.push(`Invalid [RSAA].credentials: ${credentials}`);
    }
  }
  if (
    typeof bailout !== 'undefined' &&
    typeof bailout !== 'boolean' &&
    typeof bailout !== 'function'
  ) {
    validationErrors.push(
      '[RSAA].bailout property must be undefined, a boolean, or a function'
    );
  }

  if (typeof types === 'undefined') {
    validationErrors.push('[RSAA] must have a types property');
  } else if (!Array.isArray(types) || types.length !== 3) {
    validationErrors.push('[RSAA].types property must be an array of length 3');
  } else {
    const [requestType, successType, failureType] = types;
    if (
      typeof requestType !== 'string' &&
      typeof requestType !== 'symbol' &&
      !isValidTypeDescriptor(requestType)
    ) {
      validationErrors.push('Invalid request type');
    }
    if (
      typeof successType !== 'string' &&
      typeof successType !== 'symbol' &&
      !isValidTypeDescriptor(successType)
    ) {
      validationErrors.push('Invalid success type');
    }
    if (
      typeof failureType !== 'string' &&
      typeof failureType !== 'symbol' &&
      !isValidTypeDescriptor(failureType)
    ) {
      validationErrors.push('Invalid failure type');
    }
  }

  if (typeof fetch !== 'undefined') {
    if (typeof fetch !== 'function') {
      validationErrors.push('[RSAA].fetch property must be a function');
    }
  }

  if (typeof ok !== 'undefined') {
    if (typeof ok !== 'function') {
      validationErrors.push('[RSAA].ok property must be a function');
    }
  }

  return validationErrors;
}
818399
function validate() {
  const errors = [].concat(
    _validateStore(),
    _validatePassword(),
    _validateThemeId(),
  );

  return {
    errors,
    isValid: errors.length === 0,
  };
}
111878
function validate($value, $key, $fields, $options, $exists, \CharlotteDunois\Validation\Validator $validator) {
        if(isset($_FILES[$key])) {
            if(!\file_exists($_FILES[$key]['tmp_name'])) {
                return 'formvalidator_make_image';
            }
            
            $size = \getimagesize($_FILES[$key]['tmp_name']);
        } else {
            if(!$exists) {
                return false;
            }
            
            $size = @\getimagesizefromstring($value);
        }
        
        if(!$size) {
            return 'formvalidator_make_image';
        }
        
        return true;
    }
118160
def _validate(self, writing=False):
        """"""
        if ((len(self.bits_per_component) != len(self.signed)) or
                (len(self.signed) != self.palette.shape[1])):
            msg = ("The length of the 'bits_per_component' and the 'signed' "
                   "members must equal the number of columns of the palette.")
            self._dispatch_validation_error(msg, writing=writing)
        bps = self.bits_per_component
        if writing and not all(b == bps[0] for b in bps):
            # We don't support writing palettes with bit depths that are
            # different.
            msg = "Writing palettes with varying bit depths is not supported."
            self._dispatch_validation_error(msg, writing=writing)
985
function validation($data, $files) {
        global $COURSE;

        $errors = parent::validation($data, $files);

        if (array_key_exists('idnumber', $data)) {
            if ($data['id']) {
                $grade_item = new grade_item(array('id'=>$data['id'], 'courseid'=>$data['courseid']));
            } else {
                $grade_item = null;
            }
            if (!grade_verify_idnumber($data['idnumber'], $COURSE->id, $grade_item, null)) {
                $errors['idnumber'] = get_string('idnumbertaken');
            }
        }

        return $errors;
    }
634735
def _write_validate(self):
        """"""
        if self.colorspace is None:
            msg = ("Writing colr boxes without enumerated "
                   "colorspaces is not supported at this time.")
            self._dispatch_validation_error(msg, writing=True)

        if self.icc_profile is None:
            if self.colorspace not in [SRGB, GREYSCALE, YCC]:
                msg = ("Colorspace should correspond to one of SRGB, "
                       "GREYSCALE, or YCC.")
                self._dispatch_validation_error(msg, writing=True)

        self._validate(writing=True)
1258273
function validation($data, $files) {
        global $USER;
        $errors = parent::validation($data, $files);
        $reason = null;

        // ignore submitted username
        if (!$user = authenticate_user_login($USER->username, $data['password'], true, $reason, false)) {
            $errors['password'] = get_string('invalidlogin');
            return $errors;
        }

        if ($data['newpassword1'] <> $data['newpassword2']) {
            $errors['newpassword1'] = get_string('passwordsdiffer');
            $errors['newpassword2'] = get_string('passwordsdiffer');
            return $errors;
        }

        if ($data['password'] == $data['newpassword1']){
            $errors['newpassword1'] = get_string('mustchangepassword');
            $errors['newpassword2'] = get_string('mustchangepassword');
            return $errors;
        }

        if (user_is_previously_used_password($USER->id, $data['newpassword1'])) {
            $errors['newpassword1'] = get_string('errorpasswordreused', 'core_auth');
            $errors['newpassword2'] = get_string('errorpasswordreused', 'core_auth');
        }

        $errmsg = '';//prevents eclipse warnings
        if (!check_password_policy($data['newpassword1'], $errmsg)) {
            $errors['newpassword1'] = $errmsg;
            $errors['newpassword2'] = $errmsg;
            return $errors;
        }

        return $errors;
    }
927893
function stamp(obj) {
    if (!obj.__fe_id) {
        lastId += 1;
        obj.__fe_id = lastId; // eslint-disable-line camelcase
    }

    return obj.__fe_id;
}
1150346
def _validate(self, writing=False):
        """"""
        for box in self.DR:
            if box.box_id != 'url ':
                msg = ('Child boxes of a data reference box can only be data '
                       'entry URL boxes.')
                self._dispatch_validation_error(msg, writing=writing)
338177
function validated(invalid){
            if (invalid) { return callback(invalid) }
            if(options.coerce){crudUtils.coerceData(options,coerced())}
            else{coerced(null,options.data)}
        }
1124157
def _validate_rfilter(self, rfilter, letter="d"):
        """"""
        if letter == "d":
            pexdoc.exh.addai(
                "dfilter",
                (
                    (not self._has_header)
                    and any([not isinstance(item, int) for item in rfilter.keys()])
                ),
            )
        else:
            pexdoc.exh.addai(
                "rfilter",
                (
                    (not self._has_header)
                    and any([not isinstance(item, int) for item in rfilter.keys()])
                ),
            )
        for key in rfilter:
            self._in_header(key)
            rfilter[key] = (
                [rfilter[key]] if isinstance(rfilter[key], str) else rfilter[key]
            )
497857
function isValidIdentifierCharacter(ch) {
  if (!ch) {
    return false
  }

  return (
    0x2d == code(ch) || // '-'
    0x2e == code(ch) || // '.'
    0x3a == code(ch) || // ':'
    inRange(code(ch), 0x30, 0x39) || // 0-9 (DIGIT)
    inRange(code(ch), 0x61, 0x7a) || // a-z (ALPHA)
    inRange(code(ch), 0x41, 0x5a)    // A-Z (ALPHA)
  )
}
939644
function validateCustom(attr, conf, err, done) {
    conf.customValidator.call(this, err, done);
}
1251024
function validateHTTPInput( $http, $base, $workflowEvent, &$validation )
    {
        $returnState = eZInputValidator::STATE_ACCEPTED;
        $reason = array();

        if ( !$http->hasSessionVariable( 'BrowseParameters' ) )
        {
            // No validation when deleting to avoid blocking deletion of invalid items
            if (
                $http->hasPostVariable( 'DeleteApproveUserIDArray_' . $workflowEvent->attribute( 'id' ) ) ||
                $http->hasPostVariable( 'DeleteApproveGroupIDArray_' . $workflowEvent->attribute( 'id' ) )
            )
            {
                return eZInputValidator::STATE_ACCEPTED;
            }

            // check approve-users
            $approversIDs = array_unique( $this->attributeDecoder( $workflowEvent, 'approve_users' ) );
            if ( is_array( $approversIDs ) and
                 count( $approversIDs ) > 0 )
            {
                $returnState = eZApproveType::validateUserIDList( $approversIDs, $reason );
            }
            else
                $returnState = false;

            if ( $returnState != eZInputValidator::STATE_INVALID )
            {
                // check approve-groups
                $userGroupIDList = array_unique( $this->attributeDecoder( $workflowEvent, 'approve_groups' ) );
                if ( is_array( $userGroupIDList ) and
                     count( $userGroupIDList ) > 0 )
                {
                    $returnState = eZApproveType::validateGroupIDList( $userGroupIDList, $reason );
                }
                else if ( $returnState === false )
                {
                    // if no one user or user-group was passed as approvers
                    $returnState = eZInputValidator::STATE_INVALID;
                    $reason[ 'text' ] = "There must be passed at least one valid user or user group who approves content for the event.";
                }

                // check excluded-users
                /*
                if ( $returnState != eZInputValidator::STATE_INVALID )
                {
                    // TODO:
                    // ....
                }
                */

                // check excluded-groups
                if ( $returnState != eZInputValidator::STATE_INVALID )
                {
                    $userGroupIDList = array_unique( $this->attributeDecoder( $workflowEvent, 'selected_usergroups' ) );
                    if ( is_array( $userGroupIDList ) and
                         count( $userGroupIDList ) > 0 )
                    {
                        $returnState = eZApproveType::validateGroupIDList( $userGroupIDList, $reason );
                    }
                }
            }
        }
        else
        {
            $browseParameters = $http->sessionVariable( 'BrowseParameters' );
            if ( isset( $browseParameters['custom_action_data'] ) )
            {
                $customData = $browseParameters['custom_action_data'];
                if ( isset( $customData['event_id'] ) and
                     $customData['event_id'] == $workflowEvent->attribute( 'id' ) )
                {
                    if ( !$http->hasPostVariable( 'BrowseCancelButton' ) and
                         $http->hasPostVariable( 'SelectedObjectIDArray' ) )
                    {
                        $objectIDArray = $http->postVariable( 'SelectedObjectIDArray' );
                        if ( is_array( $objectIDArray ) and
                             count( $objectIDArray ) > 0 )
                        {
                            switch( $customData['browse_action'] )
                            {
                            case "AddApproveUsers":
                                {
                                    $returnState = eZApproveType::validateUserIDList( $objectIDArray, $reason );
                                } break;
                            case 'AddApproveGroups':
                            case 'AddExcludeUser':
                                {
                                    $returnState = eZApproveType::validateGroupIDList( $objectIDArray, $reason );
                                } break;
                            case 'AddExcludedGroups':
                                {
                                    // TODO:
                                    // .....
                                } break;
                            }
                        }
                    }
                }
            }
        }

        if ( $returnState == eZInputValidator::STATE_INVALID )
        {
            $validation[ 'processed' ] = true;
            $validation[ 'events' ][] = array( 'id' => $workflowEvent->attribute( 'id' ),
                                               'placement' => $workflowEvent->attribute( 'placement' ),
                                               'workflow_type' => &$this,
                                               'reason' => $reason );
        }
        return $returnState;
    }