Searches the record for any errors and returns them

 @return [ActiveModel::Errors] the error object for the current record

 @raise [AttributeNotFound] when the attribute is not found in the record
966171
def errors
      found_errors = @record.all('[data-error-for]')
      error_list = ActiveModel::Errors.new(self)
      found_errors.each do | error |
        attribute = error['data-error-for']
        message = error.text
        error_list.add(attribute, message)
      end
      error_list
    end
1022908
def validate_each(record, attribute, value)
      unless value =~ EmailValidator.pattern
        record.errors.add(attribute, options[:message] || :invalid_email)
      end
    end
824387
def filter(self, record):
        
        found = self._pattern.search(record.getMessage())
        return not found
1008536
def valid?
    @errors = (defined?(HashWithIndifferentAccess) ? HashWithIndifferentAccess : ActiveSupport::HashWithIndifferentAccess).new
    
    self.class._module.required_fields.each do |attribute|
      valid_attribute?(attribute)
    end
    
    # for rails compatibility
    def @errors.full_messages
      # After removing attributes without errors, flatten the error hash, repeating the name of the attribute before each message:
      # e.g. {'name' => ['cannot be blank', 'is too long'], 'website' => ['is not valid']}
      # will become 'name cannot be blank, name is too long, website is not valid
      self.inject([]){|memo, obj| memo.concat(obj[1].inject([]){|m, o| m << "#{obj[0].to_s.humanize} #{o}" })}
    end
    
    # Rails needs each attribute to be present in the error hash (if the attribute has no error, it has [] as a value)
    # Redefine the [] method for the errors hash to return [] instead of nil is the hash doesn't contain the key
    class << @errors
      alias :old_key_lookup :[]
      def [](key)
        old_key_lookup(key) || Array.new
      end
    end
    
    @errors.size == 0
  end
204233
def add_errors(errors)
      errors.each do |error|
        if error.respond_to?(:message)
          self.errors.add(error.field, error.message)
        elsif error.respond_to?(:messages)
          error.messages.each do |message|
            self.errors.add(error.field, message)
          end
        end
      end
    end
1239115
def validate(record, field_name, bindings = {})
      if validations
        validations.collect do |validation|
          unless valid_value?(validation, record, field_name, bindings)
            FieldValidationError.new(validation, record, field_name, pos, width)
          end
        end.compact
      elsif record && record[field_name]
        # when no validation rules exist for the field, just check if the field exists in the record
        []
      else
        raise "found field value nil in #{record} field #{field_name}, shouldn't be possible?"
      end
    end
642919
function getErrors()
    {
        if (!$this->errors){
            $this->errors = new Error('Ошибки', 'errors', null, true);
        }
        return $this->errors;
    }
1193804
public function getMissingErrors()
    {
        return array_combine(
            array_keys($this->missingAttribs),
            array_map(function ($ref) {
                return $ref['error'];
            }, array_values($this->missingAttribs))
        );
    }
1069886
def method_missing(id, *args, &block)
      ids = id.to_s
      if instance_variable_defined?(:@attributes)
        return @attributes[id] if @attributes.has_key?(id)
        return @attributes[ids] if @attributes.has_key?(ids)
      end
      raise NoMethodError.new("#{ids} not found", name)
    end
331277
def record_from_current_or_find(klass, id, current)
      if current.is_a?(ActiveRecord::Base) && current.id.to_s == id
        # modifying the current object of a singular association
        current
      elsif current.respond_to?(:any?) && current.any? { |o| o.id.to_s == id }
        # modifying one of the current objects in a plural association
        current.detect { |o| o.id.to_s == id }
      else # attaching an existing but not-current object
        klass.find(id)
      end
    end
1255803
def get_error(self, i=None, unit=None,
                  uncover=None, trail=None,
                  linebreak=None, sort_by_indep=None):
        
        return self.get_value(i=i, unit=unit,
                              uncover=uncover, trail=trail,
                              linebreak=linebreak, sort_by_indep=sort_by_indep,
                              attr='_error')
1362267
def errors
      xsd = Nokogiri::XML::Schema(File.open(AIXM.schema(:xsd)))
      xsd.validate(Nokogiri::XML(to_xml)).reject do |error|
        AIXM.config.ignored_errors && error.message.match?(AIXM.config.ignored_errors)
      end
    end
1301561
def find_or_create_for_params(params, parent_column, parent_record)
      current = parent_record.send(parent_column.name)
      klass = parent_column.association.klass
      if params.key? klass.primary_key
        record_from_current_or_find(klass, params[klass.primary_key], current)
      elsif klass.authorized_for?(:crud_type => :create)
        association = parent_column.association
        record = association.klass.new
        if association.reverse_association&.belongs_to? && (association.collection? || current.nil?)
          record.send("#{parent_column.association.reverse}=", parent_record)
        end
        record
      end
    end
991333
def inherit_errors(error_object)
      error_object = error_object.errors if error_object.respond_to?(:errors)

      error_object.each do |k, v|
        next if _error_ignores[k.to_sym]

        if respond_to?(k)
          errors.add(k, v)
        elsif _error_map[k.to_sym]
          errors.add(_error_map[k.to_sym], v)
        else
          errors.add(:base, error_object.full_message(k, v))
        end
      end

      false
    end
108443
def perform(id, method, *args)
      if id
        begin
          self.class.find(id).send(method, *args)
        rescue ActiveRecord::RecordNotFound
          # If the record was deleted after the job was created, swallow it
        end
      else
        self.class.send(method, *args)
      end
    end
146648
def associated_records_to_validate_or_save(association,
                                               new_record,
                                               autosave)
      if new_record || autosave
        association && association.target
      else
        association.target.find_all(&:new_record?)
      end
    end
1217893
function(err){
                var error = null,
                    keys = null,
                    errMsg = '';

                if(err.name == 'ValidationError'){
                    keys = _.keys(err.errors);

                    if(err.errors[keys[0]].path === 'salt'){
                        //Support for virtual fields.
                        errMsg = err.errors[keys[0]].message;
                    }
                    else if(err.errors[keys[0]].type === 'required'){
                        errMsg = '"' + err.errors[keys[0]].path + '" is a required field.';
                    }
                    else {
                        errMsg = err.errors[keys[0]].message;
                    }

                    error = createError(400, errMsg);
                }
                else if (err.name == 'MongoError' && (err.code == '11001' || err.code == '11000')) {
                    error = createError(400, 'Duplicate key already exists.');
                }
                else {
                    error = createError(err);
                }

                return error;
            }