Call the form is_valid to ensure every value supplied is valid
962068
def clean(self, value):
        
        if not value:
            raise ValidationError(
                'Error found in Form Field: Nothing to validate')

        data = dict((bf.name, value[i]) for i, bf in enumerate(self.form))
        self.form = form = self.form.__class__(data)
        if not form.is_valid():
            error_dict = list(form.errors.items())
            raise ValidationError([
                ValidationError(mark_safe('{} {}'.format(
                    k.title(), v)), code=k) for k, v in error_dict])

        # This call will ensure compress is called as expected.
        return super(FormField, self).clean(value)
28226
def are_forms_valid(self, forms):
        
        for form in six.itervalues(forms):
            if not form.is_valid():
                return False
        return True
634538
def form_valid(self, form):
        '''
        
        '''
        slotIds = form.cleaned_data['slotIds']
        deleteSlot = form.cleaned_data.get('deleteSlot', False)

        these_slots = InstructorAvailabilitySlot.objects.filter(id__in=slotIds)

        if deleteSlot:
            these_slots.delete()
        else:
            for this_slot in these_slots:
                this_slot.location = form.cleaned_data['updateLocation']
                this_slot.room = form.cleaned_data['updateRoom']
                this_slot.status = form.cleaned_data['updateStatus']
                this_slot.pricingTier = form.cleaned_data.get('updatePricing')
                this_slot.save()

        return JsonResponse({'valid': True})
1016496
def form_valid(self, form):
        """"""
        auth_login(self.request, form.get_user())
        return HttpResponseRedirect(self.get_success_url())
714026
def form_valid(self, form):
        '''  '''

        startDate = form.cleaned_data.get('startDate')
        repeatEvery = form.cleaned_data.get('repeatEvery')
        periodicity = form.cleaned_data.get('periodicity')
        quantity = form.cleaned_data.get('quantity')
        endDate = form.cleaned_data.get('endDate')

        # Create a list of start dates, based on the passed  values of repeatEvery,
        # periodicity, quantity and endDate.  This list will be iterated through to
        # create the new instances for each event.
        if periodicity == 'D':
            delta = {'days': repeatEvery}
        elif periodicity == 'W':
            delta = {'weeks': repeatEvery}
        elif periodicity == 'M':
            delta = {'months': repeatEvery}

        repeat_list = []
        this_date = startDate

        if quantity:
            for k in range(0, quantity):
                repeat_list.append(this_date)
                this_date = this_date + relativedelta(**delta)
        elif endDate:
            while (this_date <= endDate):
                repeat_list.append(this_date)
                this_date = this_date + relativedelta(**delta)

        # Now, loop through the events in the queryset to create duplicates of them
        for event in self.queryset:

            # For each new occurrence, we determine the new startime by the distance from
            # midnight of the first occurrence date, where the first occurrence date is
            # replaced by the date given in repeat list
            old_min_time = event.localStartTime.replace(hour=0, minute=0, second=0, microsecond=0)

            old_occurrence_data = [
                (x.startTime - old_min_time, x.endTime - old_min_time, x.cancelled)
                for x in event.eventoccurrence_set.all()
            ]

            old_role_data = [(x.role, x.capacity) for x in event.eventrole_set.all()]

            for instance_date in repeat_list:

                # Ensure that time zones are treated properly
                combined_datetime = datetime.combine(instance_date, datetime.min.time())
                new_datetime = ensure_timezone(combined_datetime, old_min_time.tzinfo)

                # Removing the pk and ID allow new instances of the event to
                # be created upon saving with automatically generated ids.
                event.id = None
                event.pk = None
                event.save()

                # Create new occurrences
                for occurrence in old_occurrence_data:
                    EventOccurrence.objects.create(
                        event=event,
                        startTime=new_datetime + occurrence[0],
                        endTime=new_datetime + occurrence[1],
                        cancelled=occurrence[2],
                    )

                # Create new event-specific role data
                for role in old_role_data:
                    EventRole.objects.create(
                        event=event,
                        role=role[0],
                        capacity=role[1],
                    )

                # Need to save twice to ensure that startTime etc. get
                # updated properly.
                event.save()

            return super(RepeatEventsView, self).form_valid(form)
596025
def validate(self, value):
        """"""

        # check choices
        if self.choices:
            if isinstance(self.choices[0], (list, tuple)):
                option_keys = [k for k, v in self.choices]
                if value not in option_keys:
                    msg = ('Value {0} is not listed among valid choices {1}'.format(value, option_keys))
                    self.raise_error(msg)
            elif value not in self.choices:
                msg = ('Value {0} is not listed among valid choices {1}'.format(value, self.choices))
                self.raise_error(msg)
975649
def is_valid(self):
        
        self.cleaned_data = {}
        self.changed_fields = []
        self.validated = False
        self._errors = {}
        self._named_errors = {}
        cleaned_data = {}
        changed_fields = []
        errors = {}
        named_errors = {}

        # Validate sub forms
        for name, subform in self._forms.items():
            if not subform.is_valid():
                errors[name] = subform._errors
                named_errors.update(subform._named_errors)
                continue
            if subform.has_changed:
                changed_fields.append(name)

        # Validate sub sets
        for name, formset in self._sets.items():
            if not formset.is_valid():
                errors[name] = formset._errors
                named_errors.update(formset._named_errors)
                continue
            if formset.has_changed:
                changed_fields.append(name)

        # Validate each field
        for name, field in self._fields.items():
            field.error = None
            py_value = field.validate(self)
            if field.error:
                errors[name] = field.error
                named_errors[field.name] = field.error
                continue
            cleaned_data[name] = py_value
            if hasattr(field, '_deleted'):
                cleaned_data[name] = None
                field.has_changed = True
            if field.has_changed:
                changed_fields.append(name)

        # Validate relation between fields
        for name, field in self._fields.items():
            field.validate(self, cleaned_data)
            if field.error:
                errors[name] = field.error
                named_errors[field.name] = field.error
                continue

        if errors:
            self._errors = errors
            self._named_errors = named_errors
            return False

        self.changed_fields = changed_fields
        self.cleaned_data = self.clean(cleaned_data)
        self.validated = True
        return True
257224
def set_valid(self, boolean):
        '''
        
        '''
        old_state = self.is_valid()
        self.valid_file = boolean

        if old_state != self.valid_file:
            self.call_valid(self.valid_file)
790044
def form_valid(self, form):
        """"""
        instance = form.save(commit=False)
        if hasattr(self.request, 'user'):
            instance.user = self.request.user
        if settings.CONTACT_FORM_FILTER_MESSAGE:
            instance.message = bleach.clean(
                instance.message,
                tags=settings.CONTACT_FORM_ALLOWED_MESSAGE_TAGS,
                strip=settings.CONTACT_FORM_STRIP_MESSAGE
            )
        instance.ip = get_user_ip(self.request)
        instance.site = self.site
        instance.save()
        if settings.CONTACT_FORM_USE_SIGNALS:
            contact_form_valid.send(
                sender=self,
                event=self.valid_event,
                ip=instance.ip,
                site=self.site,
                sender_name=instance.sender_name,
                sender_email=instance.sender_email,
                email=instance.subject.department.email,
                subject=instance.subject.title,
                message=instance.message
            )

        return super(ContactFormView, self).form_valid(form)
718714
def form_valid(self, form):
        
        #noinspection PyAttributeOutsideInit
        self.object = form.save()

        # Index the link.
        for backend in get_search_backends():
            backend.add(self.object)

        #noinspection PyUnresolvedReferences
        return render_modal_workflow(
            self.request,
            None,
            '{0}/chosen.js'.format(self.template_dir),
            {'obj': self.get_json(self.object)}
        )
1285896
def validate(self, value):
        
        if self.required and not value:
            raise OAuthValidationError({'error': 'invalid_request'})

        # Validate that each value in the value list is in self.choices.
        for val in value:
            if not self.valid_value(val):
                raise OAuthValidationError({
                    'error': 'invalid_request',
                    'error_description': _("'%s' is not a valid scope.") % \
                            val})
1281735
def form_valid(self, form):
        
        response = self.ulogin_response(form.cleaned_data['token'],
                                        self.request.get_host())

        if 'error' in response:
            return render(self.request, self.error_template_name,
                          {'json': response})

        if user_is_authenticated(get_user(self.request)):
            user, identity, registered = \
                self.handle_authenticated_user(response)
        else:
            user, identity, registered = \
                self.handle_anonymous_user(response)

        assign.send(sender=ULoginUser,
                    user=get_user(self.request),
                    request=self.request,
                    registered=registered,
                    ulogin_user=identity,
                    ulogin_data=response)
        return redirect(self.request.GET.get(REDIRECT_FIELD_NAME) or '/')
1313899
def __CheckValid(self, value):
        ""
        val = self.__val
        self.is_valid = True
        try:
            val = set_float(value)
            if self.__min is not None and (val < self.__min):
                self.is_valid = False
                val = self.__min
            if self.__max is not None and (val > self.__max):
                self.is_valid = False
                val = self.__max
        except:
            self.is_valid = False
        self.__bound_val = self.__val = val
        fgcol, bgcol = self.fgcol_valid, self.bgcol_valid
        if not self.is_valid:
            fgcol, bgcol = self.fgcol_invalid, self.bgcol_invalid

        self.SetForegroundColour(fgcol)
        self.SetBackgroundColour(bgcol)
        self.Refresh()
986043
def form_valid(self, post_form, attachment_formset, poll_option_formset, **kwargs):
        
        save_poll_option_formset = poll_option_formset is not None \
            and not self.preview

        valid = super().form_valid(
            post_form, attachment_formset, poll_option_formset=poll_option_formset, **kwargs)

        if save_poll_option_formset:
            poll_option_formset.topic = self.forum_post.topic
            poll_option_formset.save(
                poll_question=post_form.cleaned_data.pop('poll_question', None),
                poll_max_options=post_form.cleaned_data.pop('poll_max_options', None),
                poll_duration=post_form.cleaned_data.pop('poll_duration', None),
                poll_user_changes=post_form.cleaned_data.pop('poll_user_changes', None),
            )

        return valid
34753
def assert_valid_value(value)
      unless valid?(value)
        raise Property::InvalidValueError.new(self,value)
      end
      true
    end
301637
def validate(self, value):
        ''''''
        if not self.blank and value == '':
            self.error_message = 'Can not be empty.  Please provide a value.'
            return False
        self._choice = value
        return True
758014
def valid?
      valid = true

      rules.each_pair do |field, rules|
        if ! @obj.respond_to?(field)
          raise InvalidKey, "cannot validate non-existent field '#{field}'"
        end

        rules.each do |r|
          if ! r.valid_value?(@obj.send(field))
            valid = false
            errors[field] = {:rule => r.error_key, :params => r.params}
            break
          end
        end
      end

      @valid = valid
    end