Validates specified `form` for presence of all required fields.
 @param [Hash] form Form to validate.
 @param [Hash] fields Fields to test.
 return void
 @raise ContractError
767788
def validate_presence_of_required_fields form, fields
      absent_fields = []
      fields.each_pair do |key, opts|
        next  unless opts[:required]
        if !form.has_key?(key) || form[key].nil?
          absent_fields << key
        end
      end
      unless absent_fields.empty?
        raise RegApi2::ContractError.new(
          "Required fields missed: #{absent_fields.join(', ')}",
          absent_fields
        )
      end
      nil
    end
768465
def form_valid(self, form):
        
        response = super().form_valid(form)
        messages.success(self.request, self.success_message)
        return response
411813
public void attachFormValidator(final Form<?> form, final FormValidator validator) {
        form.add(new AbstractFormValidator() {

            private static final long serialVersionUID = -4181095793820830517L;

            @Override
            public void validate(Form<?> form) {
                Map<String, FormComponent<?>> loadFormComponents = loadFormComponents(form);
                Map<String, String> toValidate = new HashMap<String, String>();
                for (Map.Entry<String, FormComponent<?>> entry : loadFormComponents.entrySet()) {
                    toValidate.put(entry.getKey(), entry.getValue().getValue());
                }
                try {
                    validator.validate(toValidate);
                } catch (ConnectorValidationFailedException e) {
                    Map<String, String> attributeErrorMessages = e.getErrorMessages();
                    for (Map.Entry<String, String> entry : attributeErrorMessages.entrySet()) {
                        FormComponent<?> fc = loadFormComponents.get(entry.getKey());
                        fc.error(new ValidationError().setMessage(entry.getValue()));
                    }
                }

            }

            @Override
            public FormComponent<?>[] getDependentFormComponents() {
                Collection<FormComponent<?>> formComponents = loadFormComponents(form).values();
                return formComponents.toArray(new FormComponent<?>[formComponents.size()]);
            }

            private Map<String, FormComponent<?>> loadFormComponents(final Form<?> form) {
                Map<String, FormComponent<?>> formComponents = new HashMap<String, FormComponent<?>>();
                if (validator != null) {
                    for (String attribute : validator.fieldsToValidate()) {
                        Component component =
                            form.get("attributesPanel:fields:" + attribute + ":row:field");
                        if (component instanceof FormComponent<?>) {
                            formComponents.put(attribute, (FormComponent<?>) component);
                        }
                    }
                }
                return formComponents;
            }
        });
    }
361445
def supress_form_field_errors
      original_proc = ActionView::Base.field_error_proc
      ActionView::Base.field_error_proc = proc { |input, _instance| input }
      yield
    ensure
      ActionView::Base.field_error_proc = original_proc
    end
569099
def _validate_excludes(self, excluded_fields, field, value):
        
        if isinstance(excluded_fields, Hashable):
            excluded_fields = [excluded_fields]

        # Mark the currently evaluated field as not required for now if it actually is.
        # One of the so marked will be needed to pass when required fields are checked.
        if self.schema[field].get('required', self.require_all):
            self._unrequired_by_excludes.add(field)

        for excluded_field in excluded_fields:
            if excluded_field in self.schema and self.schema[field].get(
                'required', self.require_all
            ):

                self._unrequired_by_excludes.add(excluded_field)

        if any(excluded_field in self.document for excluded_field in excluded_fields):
            exclusion_str = ', '.join(
                "'{0}'".format(field) for field in excluded_fields
            )
            self._error(field, errors.EXCLUDES_FIELD, exclusion_str)
332956
def field_ok?(field)
      raise JSS::InvalidDataError, "Field elements must be hashes with :name, :type, and possibly :choices" unless field.kind_of? Hash
      raise JSS::InvalidDataError, "Fields require names" if field[:name].to_s.empty?
      raise JSS::InvalidDataError, "Fields :type must be one of: :#{FIELD_TYPES.join(', :')}" unless FIELD_TYPES.include? field[:type].to_sym

      if field[:type].to_sym == :menu
        unless field[:choices].kind_of? Array and  field[:choices].reject{|c| c.kind_of? String}.empty?
          raise JSS::InvalidDataError, "Choices for menu fields must be an Array of Strings"
        end # unless
      else
        field[:choices] = []
      end # if type -- menu
      true
    end
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
579330
def validate(self, form_cls, obj=None):
        ''''''
        if 'application/json' not in request.headers.get('Content-Type'):
            errors = {'Content-Type': 'expecting application/json'}
            self.abort(400, errors=errors)
        form = form_cls.from_json(request.json, obj=obj, instance=obj,
                                  csrf_enabled=False)
        if not form.validate():
            self.abort(400, errors=form.errors)
        return form
928571
protected function validateRelationFields()
    {
        if (empty($this->submittedValues['sendCustomer']) && !empty($this->submittedValues['emailAsPdf'])) {
            $this->warningMessages['conflicting_options'] = $this->t('message_validate_conflicting_options');
        }
    }
680211
function performValidation(field) {
        return function(rule, cb) {
            var valueToBeValidated = kontx.args.fields[field._id],
                validate = validator.get(rule);

            //Undefined values do not need to be validated unless the field is required
            if (rule.type === 'required' || !_.isUndefined(valueToBeValidated)) {
                if (_.isArray(valueToBeValidated)) {
                    q.all(
                        _.map(valueToBeValidated, function(value) {
                            return validate(value, rule.options);
                        })
                    )
                        .then(
                            function() {
                                cb();
                            },
                            function() {
                                cb(createError(400, validationTemplate({
                                    label: field.label
                                })));
                            }
                    );
                } else {
                    validate(valueToBeValidated, rule.options)
                        .then(
                            function() {
                                cb();
                            },
                            function() {
                                cb(createError(400, validationTemplate({
                                    label: field.label
                                })));
                            }
                    );
                }
            } else {
                cb();
            }
        };
    }
28226
def are_forms_valid(self, forms):
        
        for form in six.itervalues(forms):
            if not form.is_valid():
                return False
        return True
988328
public function validate(array $form) {
        $this->isValid = true;
        foreach($form as $field => $value) {
            if(array_key_exists($field , $this->validation )) {
                $this->validField($field , $value, $this->validation[$field]);
            }
        }
        return $this;
    }
572231
def ensure_valid_field!(field)
      if self.class.columns_hash["#{field}"].nil?
        raise ArgumentError, "Column :#{field} does not exist"
      elsif !%i(text binary).include?(self.class.columns_hash["#{field}"].type)
        raise ArgumentError, "Column :#{field} must be of type 'text' or 'binary' \
to be used for encryption"
      end
    end
686480
def form_valid(self, form, formsets):
        
        # check if it's a new object before it save the form
        new_object = False
        if not self.object:
            new_object = True

        instance = getattr(form, 'instance', None)
        auto_tags, changed_tags, old_tags = tag_handler.get_tags_from_data(
            form.data, self.get_tags(instance))
        tag_handler.set_auto_tags_for_form(form, auto_tags)

        with transaction.commit_on_success():
            self.object = self.save_form(form)
            self.save_formsets(form, formsets, auto_tags=auto_tags)

            url = self.get_object_url()
            self.log_action(self.object, CMSLog.SAVE, url=url)
            msg = self.write_message()

        # get old and new tags
        if not new_object and changed_tags and old_tags:
            tag_handler.update_changed_tags(changed_tags, old_tags)

        return self.success_response(msg)
382363
public function validate(array $fields)
    {
        $this->flashInput($fields);

        $rules = $this->getValidationRules($fields);

        $validator = $this->getValidatorInstance($rules);

        if($validator->fails()){

            $this->failedValidation($validator);
        }
    }
427691
public void validateAllFields() {

        CmsValidationController validationController = new CmsValidationController(
            m_fields.values(),
            createValidationHandler());
        validationController.setFormValidator(m_validatorClass);
        validationController.setFormValidatorConfig(createValidatorConfig());
        startValidation(validationController);
    }
860388
def __validate_required_fields(self, document):
        
        try:
            required = set(field for field, definition in self.schema.items()
                           if self._resolve_rules_set(definition).
                           get('required') is True)
        except AttributeError:
            if self.is_child and self.schema_path[-1] == 'schema':
                raise _SchemaRuleTypeError
            else:
                raise
        required -= self._unrequired_by_excludes
        missing = required - set(field for field in document
                                 if document.get(field) is not None or
                                 not self.ignore_none_values)

        for field in missing:
            self._error(field, errors.REQUIRED_FIELD)

        # At least on field from self._unrequired_by_excludes should be
        # present in document
        if self._unrequired_by_excludes:
            fields = set(field for field in document
                         if document.get(field) is not None)
            if self._unrequired_by_excludes.isdisjoint(fields):
                for field in self._unrequired_by_excludes - fields:
                    self._error(field, errors.REQUIRED_FIELD)