Perform validation only if data has been submitted
518780
def validate(self, form, extra_validators=tuple()):
        ''''''
        if not self.has_data:
            return True
        if self.is_list_data:
            if not isinstance(self._formdata[self.name], (list, tuple)):
                return False
        return super(NestedModelList, self).validate(form, extra_validators)
1237197
public function validate()
    {
        foreach ($this->getFields() as $field) {
            if (! isset($this->submittedData[$field->getName()])) {
                continue;
            }
            
            // is it mandatory and empty?
            if ($field->isMandatory() && strlen($this->submittedData[$field->getName()]) < 1) {
                $mandatory = new ValidationError($field, 'is mandatory');
                $field->addError($mandatory);

                // Go to the next field, no need to validate
                continue;
            }

            $validationResult = $field->validate();

            if ($validationResult) {
                $validationError = new ValidationError($field);
                $field->addError($validationError);
            }
        }
    }
1206761
async function validateData (args) {
    debug('validate '+this.name)
    // query all records and iterate over response
    var res = await this.query({
        // skip access control checks
        allow: true,
        // do not cache
        cache: false,
        // make sure session is object
        session: args.session,
    })
    // get response
    debug('checking '+res.length+' records')
    // iterate over records waiting for promise to be resolved
    await res.each(async (rec, num) => {
        // set to true if column needs to be updated
        var needsUpdate = false
        // check if any columns do not match
        _.each(this.extraColumns, (spec, name) => {
            // skip if no data
            if (!rec.data) {
                return
            }
            // if already updating or column value does not match data
            // value then set the update flag to true
            if (needsUpdate || rec.raw[name] !== rec.data[spec.path]) {
                needsUpdate = true
            }
        })
        // go to next record if update not needed
        if (!needsUpdate) {
            return
        }
        // debug
        debug('updating record num '+num)
        // get update sql
        var update = sql.updateExtraColumns(this, rec)
        // do update
        await this.mysql().query(update.sql, update.params, {}, args.session)
        // increment update count
        this.updated++
    })
    // validate complete
    this.validated = true
}
322593
function validateForm() {

            var isValid = isEmpty(errors);

            formData = {};

            $.each(
                node.find('input:not([type="submit"]), select, textarea').not(':disabled'),
                function(index, input) {

                    input = $(input);

                    var value = _getInputValue(input[0]),
                        inputName = input.attr('name');

                    if (inputName) {
                        if (/\[]$/.test(inputName)) {
                            inputName = inputName.replace(/\[]$/, '');
                            if (!(formData[inputName] instanceof Array)) {
                                formData[inputName] = [];
                            }
                            formData[inputName].push(value)
                        } else {
                            formData[inputName] = value;
                        }
                    }

                    if (!!input.attr(_data.validation) || !!input.attr(_data.regex)) {
                        if (!validateInput(input[0], value)) {
                            isValid = false;
                        }
                    }
                }
            );

            prepareFormData();

            return isValid;

        }
805447
function validateData(data) {
        var random = Math.floor(Math.random() * (data.length - 0) + 0);

        // ensure: containing Array and Object keys
        var ok = Array.isArray(data) || data instanceof Array;
        ok = ok && ['code', 'name', 'age'].every(function (k) {
          return data[random].hasOwnProperty(k);
        });

        return ok ? data : this.respond(false, 'Supplied data is invalid');
      }
547343
def validate(self, request, value):
        
        if self.required and value == DEFAULT_FIELD_VALUE:
            return ValidationResult(is_success=False,
                                    reason='This field is required')
        if not self.nullable and value is None:
            return ValidationResult(is_success=False,
                                    reason='null is not a valid value')
        return ValidationResult(is_success=True)
821354
protected function performValidation()
    {
        // All the fixed fields declared above are objects that MUST use keys that match the regular expression: ^[a-zA-Z0-9\.\-_]+$.
        foreach (array_keys($this->attributes()) as $attribute) {
            if (is_array($this->$attribute)) {
                foreach ($this->$attribute as $k => $v) {
                    if (!preg_match('~^[a-zA-Z0-9\.\-_]+$~', $k)) {
                        $this->addError("Invalid key '$k' used in Components Object for attribute '$attribute', does not match ^[a-zA-Z0-9\.\-_]+\$.");
                    }
                }
            }
        }
    }
898002
function () {
            if (this.validate()) {
                if (this.beforeSubmitEvent.fire()) {
                    this.doSubmit();
                    this.submitEvent.fire();
    
                    if (this.cfg.getProperty("hideaftersubmit")) {
                        this.hide();
                    }
    
                    return true;
                } else {
                    return false;
                }
            } else {
                return false;
            }
        }
994654
def _validated(self, data):
        """"""
        for sub in self.schemas:
            data = sub(data)
        return data
355633
def _validate(self, data):
        """"""

        errors = {}

        # if the validator is not enabled, return the empty error dict
        if not self._enabled:
            return errors

        for field in self.validators:

            field_errors = []

            for validator in self.validators[field]:
                try:
                    validator(data.get(field, None))
                except ValidationError as e:
                    field_errors += e.messages

            # if there were errors, cast to ErrorList for output convenience
            if field_errors:
                errors[field] = ErrorList(field_errors)

        return errors
725616
def form_valid(self, form):
        '''  '''
        form.cleaned_data.pop('template', None)
        self.request.session[EMAIL_VALIDATION_STR] = {'form_data': form.cleaned_data}
        return HttpResponseRedirect(reverse('emailConfirmation'))
581500
def _validate_output_data(
        self, original_res, serialized_res, formatted_res, request):
        

        validator = self.representation

        # when not to validate...
        if not validator:
            return

        try:
            if isinstance(serialized_res, (list, tuple)):
                map(validator.validate, serialized_res)
            else:
                validator.validate(serialized_res)
        except ValidationError, exc:
            self._output_validation_failed(exc, serialized_res, request)
176489
protected function validateEditDashboard()
    {
        $submitted = $this->setSubmitted('dashboard');

        foreach ($submitted as &$item) {
            $item['status'] = !empty($item['status']);
            $item['weight'] = intval($item['weight']);
        }

        $this->setSubmitted(null, $submitted);
    }
1178073
def validate(cls, event_info):
        """"""
        assert 'routing_key' in event_info
        assert isinstance(event_info['routing_key'], six.string_types)
        assert 'event_action' in event_info
        assert event_info['event_action'] in cls.EVENT_TYPES
        assert 'payload' in event_info
        payload = event_info['payload']
        assert payload['summary']
        assert payload['source']
        assert payload['severity'] in cls.SEVERITY_TYPES
586311
def _validated(self, value):
        """"""
        if value is None:
            return None
        try:
            return self._format_num(value)
        except (TypeError, ValueError):
            self.fail('invalid', input=value)
        except OverflowError:
            self.fail('too_large', input=value)
959216
def validate_login(ctx, param, value):
    """"""
    # pylint: disable=unused-argument
    value = value.strip()
    if not value:
        raise click.BadParameter("The value cannot be blank.", param=param)
    return value
177584
def validate(self, value):
        
        if value in self.empty_values and self.required:
            raise ValidationError(self.error_messages['required'])