Validate all the values in the field

@param \sndsgd\field\Collection|null $collection A field collection
@return boolean True if all values are
183129
public function validate(Collection $collection = null)
    {
        $this->errors = [];
        foreach ($this->getValuesAsArray() as $index => $value) {
            # skip fields with a null value if they are not required
            if ($value === null && $this->hasRule(Rule::REQUIRED) === false) {
                continue;
            }

            foreach ($this->rules as $name => $rule) {
                $rule->setValue($value);
                $rule->setField($this, $index);
                $rule->setCollection($collection);
                if ($rule->validate() === true) {
                    $fmtValue = $rule->getValue();
                    if ($fmtValue !== $value) {
                        $value = $fmtValue;
                        $this->setValue($fmtValue, $index);
                    }
                }
                else {
                    $this->errors[] = $rule->getError();
                    break;
                }
            }
        }
        return count($this->errors) === 0;
    }
28827
public static function addCollection($collection)
  {
    static::checkConnexion();
    $r = self::$db->createCollection($collection);
    if (gettype($r) == 'object' && get_class($r) == 'MongoCollection') {
      return true;
    }
    return false;
  }
612899
protected function validateCollectionCollectionItem()
    {
        $field = 'collection_id';

        if ($this->isExcluded($field)) {
            return null;
        }

        $collection_id = $this->getSubmitted($field);

        if ($this->isUpdating() && !isset($collection_id)) {
            return null;
        }

        $label = $this->translation->text('Collection');

        if (empty($collection_id)) {
            $this->setErrorRequired($field, $label);
            return false;
        }

        if (!is_numeric($collection_id)) {
            $this->setErrorNumeric($field, $label);
            return false;
        }

        $collection = $this->collection->get($collection_id);

        if (empty($collection)) {
            $this->setErrorUnavailable($field, $label);
            return false;
        }

        $this->setSubmitted('collection', $collection);
        return true;
    }
681756
public static boolean contains(Collection<?> collection, Object value) {
		return isNotEmpty(collection) && collection.contains(value);
	}
457854
protected function verifyContainsEntitiesOnly(Collection $collection) {
			$check = $collection->forAll(function($key, $element) {
				return $element instanceof EntityInterface;
			});

			if (!$check)
				throw new \InvalidArgumentException('Items in the collection must all implement ' .
					EntityInterface::class);
		}
804567
public static function collectionToModel($collection) {
		if (is_string($collection)) {
			return \Factory::model($collection);
		} else if (!empty($collection['model'])) {
			return new \Object\Collection(['data' => $collection, 'skip_acl' => $collection['skip_acl'] ?? false]);
		} else {
			return null;
		}
	}
339133
protected function removeCollection(Collection $collection) {
		$transaction = $this->getTransactionsManager()->get(true);
			
		foreach ($collection as $model) {
			$phalconModel = $this->createTableModel($model);
			$phalconModel->setTransaction($transaction);

			if (! $phalconModel->delete()) {
				$transaction->rollback();
			}
		}

		$transaction->commit();
		return true;
	}
109446
<T extends Validatable> void validateCollection(final Collection<T> collection,
                                                  final String name) {
    Iterator<T> iterator = collection.iterator();
    int i = 0;
    while (iterator.hasNext()) {
      try {
        iterator.next().validate();
      } catch (final IllegalArgumentException e) {
        throw new IllegalArgumentException("Invalid " + name + 
            " at index " + i, e);
      }
      i++;
    }
  }
1111526
public function values($collection=null) {
    list($collection) = self::_wrapArgs(func_get_args(), 1);
    
    return self::_wrap(array_values((array) $collection));
  }
1320431
public function setAll($collection) {
		foreach ($collection as $key => $element) {
			$this->set($key, $element);
		}
		
		return $this;
	}
944128
public function apply(Collection $collection)
    {
        $this->collection = $collection;

        foreach ($this->filters() as $name => $value) {
            if (! method_exists($this, $name)) {
                continue;
            }

            if (is_array($value) or trim($value)) {
                $this->collection = $this->$name($value);
            } else {
                $this->collection = $this->$name();
            }
        }

        return $this->collection;
    }
848658
public function validate($validator)
    {
        $values = $this->getValueArray();
        $validValues = $this->getValidValues();

        // Filter out selected values not in the data source
        $self = $this;
        $invalidValues = array_filter(
            $values,
            function ($userValue) use ($self, $validValues) {
                foreach ($validValues as $formValue) {
                    if ($self->isSelectedValue($formValue, $userValue)) {
                        return false;
                    }
                }
                return true;
            }
        );
        if (empty($invalidValues)) {
            return true;
        }

        // List invalid items
        $validator->validationError(
            $this->getName(),
            _t(
                'SilverStripe\\Forms\\MultiSelectField.SOURCE_VALIDATION',
                "Please select values within the list provided. Invalid option(s) {value} given",
                array('value' => implode(',', $invalidValues))
            ),
            "validation"
        );
        return false;
    }
348378
private function _collection($collection) {
    return (!is_array($collection) && !is_object($collection)) ? str_split((string) $collection) : $collection;
  }
635334
public function validate(Control $control): bool
  {
    $options = ['options' => ['min_range' => $this->minValue,
                              'max_range' => $this->maxValue]];

    $value = $control->getSubmittedValue();

    // An empty value is valid.
    if ($value==='' || $value===null || $value===false)
    {
      return true;
    }

    // Objects and arrays are not an integer.
    if (!is_scalar($value))
    {
      return false;
    }

    // Filter valid integer values with valid range.
    $integer = filter_var($value, FILTER_VALIDATE_INT, $options);

    // If the actual value and the filtered value are not equal the value is not an integer.
    if ((string)$integer!==(string)$value)
    {
      return false;
    }

    return true;
  }
889162
public function hasCollection($collection)
    {
        if (empty($this->queriesResultCache[ 'collectionNames' ])) {
            $this->getCollections();
        }

        return (bool)in_array($collection, $this->queriesResultCache[ 'collectionNames' ]);
    }
135235
protected function validateOnPost(ErrorCollection $errors)
    {
        $this->validateData([
            Schema::KEYWORD_ID => $this->getId(),
        ], [
            Schema::KEYWORD_ID => 'required|unique:' . Model::TABLE_NAME . ',' . Model::FIELD_ID,
        ], $errors);

        $this->validateAttributes([
            Schema::ATTR_NAME => 'required|max:' . Model::LENGTH_NAME,
        ], $errors);
    }
737855
private function isCollection($property, $value)
    {
        if (!$value instanceof Collection) {
            $got = is_object($value) ? get_class($value) : gettype($value);

            throw new \InvalidArgumentException(
                sprintf('Value of "%s" property must be an instance of Collection, got %s.', $property, $got)
            );
        }
    }