Validates subject against additionalProperties

@param array $subject
@return bool
775185
public function validate($subject): bool
    {
        // Validation with "additionalProperties" applies only to the child values of instance names that do
        // not match any names in "properties", and do not match any regular expression in "patternProperties".
        $subject = $this->removePropertiesFromSubject($subject, $this->schema);
        $subject = $this->removePatternPropertiesFromSubject($subject, $this->schema);
        // The value of "additionalProperties" MUST be a valid JSON Schema (including boolean false)
        if (\is_bool($this->schema['additionalProperties']) && $this->schema['additionalProperties'] === false) {
            if (count($subject) > 0) {
                return false;
            }
        } elseif (\is_array($this->schema['additionalProperties'])) {
            foreach ($subject as $propertyValue) {
                $nodeValidator = new NodeValidator($this->schema['additionalProperties'], $this->rootSchema);
                if (!$nodeValidator->validate($propertyValue)) {
                    return false;
                }
            }
        }
        return true;
    }
678188
public function empty($subject) : bool
    {
        if (!$subject) {
            // Stringed zero - '0' - is not empty.
            return $subject !== '0';
        }
        if (is_object($subject)) {
            if ($subject instanceof \Countable) {
                return !count($subject);
            }
            if ($subject instanceof \Traversable) {
                // No need to check/use ArrayObject|ArrayIterator, because
                // those are both Countable (checked before this check).

                // Have to iterate; horrible.
                foreach ($subject as $ignore) {
                    return false;
                }
                return true;
            }
            if ($subject instanceof \ArrayAccess) {
                return false;
            }
            return !get_object_vars($subject);
        }
        return false;
    }
159478
public function ipAddress($subject) : bool
    {
        if ($subject === null) {
            return false;
        }
        $v = '' . $subject;
        return $v === '' ? false : !!filter_var($v, FILTER_VALIDATE_IP);
    }
907027
public function validate($value)
    {
        if (!is_array($value)) {
            return false;
        }

        // From json-schema definition: if "items" is not present, or its value is an object,
        // validation of the instance always succeeds, regardless of the value of "additionalItems";
        if (empty($this->items)) {
            return true;
        }

        return $this->executeItemsValidation($value);
    }
1175848
protected function isValid($value)
    {
        if (!is_array($value) && !($value instanceof \Countable)) {
            $this->addError('The given subject was not countable.', 1253718666);
            return;
        }

        $minimum = intval($this->options['minimum']);
        $maximum = intval($this->options['maximum']);
        if (count($value) < $minimum || count($value) > $maximum) {
            $this->addError('The count must be between %1$d and %2$d.', 1253718831, [$minimum, $maximum]);
        }
    }
289543
public function maxLength($subject, int $max) : bool
    {
        if ($subject === null) {
            return false;
        }
        if ($max < 0) {
            throw new InvalidArgumentException('Arg max[' . $max . '] is not non-negative.');
        }
        return strlen('' . $subject) <= $max;
    }
388905
protected function preCheckedEnum($subject, array $allowedValues) : bool
    {
        if ($subject !== null && !is_scalar($subject)) {
            return false;
        }
        foreach ($allowedValues as $allowed) {
            if ($subject === $allowed) {
                return true;
            }
        }
        return false;
    }
946910
public function validate($subject): bool
    {
        $nodeValidator = new NodeValidator($this->schema['not'], $this->rootSchema);
        if ($nodeValidator->validate($subject)) {
            return false;
        }
        return true;
    }
829521
protected function validateRequired(array $properties)
    {
        $valid = true;
        foreach ($properties as $property) {
            $value = $this->getPropertyValue($property);
            if (empty($value)) {
                $this->addError($property, sprintf('Property "%s" must not be empty.', $property));
                $valid = false;
            }
        }
        return $valid;
    }
985103
public function getMatches($subject)
    {
        preg_match('/'.$this->pattern.'/',$subject,$matches);
        return count($matches) ? $matches : false;
    }
438419
public static function convertObjectToArray($subject): array
    {
        if (!is_object($subject) && !is_array($subject)) {
            throw new \InvalidArgumentException('convertObjectToArray expects either array or object as input, ' . gettype($subject) . ' given.', 1287059709);
        }
        if (is_object($subject)) {
            $subject = (array)$subject;
        }
        foreach ($subject as $key => $value) {
            if (is_array($value) || is_object($value)) {
                $subject[$key] = self::convertObjectToArray($value);
            }
        }
        return $subject;
    }
1046169
public function validate(Validator $validator, $object, $forScenario)
    {
        if (is_object($object)) {
            //get all accessible non-static properties
            $object = get_object_vars($object);
        } else if (!is_array($object)) {
            //$object is a primitive value
            return false;
        }

        $arrayKeys = array_keys($object);
        if ($this->strict) {
            return $arrayKeys === $this->fields;
        } else {
            $diff = array_diff($this->fields, $arrayKeys);

            return empty($diff);
        }
    }
354474
public function validate($subject): bool
    {
        $validatedCount = 0;
        foreach ($this->schema['oneOf'] as $schema) {
            $nodeValidator = new NodeValidator($schema, $this->rootSchema);
            if ($nodeValidator->validate($subject)) {
                $validatedCount++;
            }
        }
        return $validatedCount === 1;
    }
820118
public function regex($subject, string $pattern) : bool
    {
        if (!$pattern) {
            throw new InvalidArgumentException('Arg pattern is empty.');
        }
        if ($subject === null) {
            return false;
        }
        return !!preg_match($pattern, '' . $subject);
    }
879971
private static function keysExist(array $keys, array $subject) : bool
    {
        foreach ($keys as $key) {
            if (!isset($subject[$key])) {
                return false;
            }
        }
        return true;
    }
35685
public function validate($subject): bool
    {
        if (\is_string($this->schema['pattern'])) {
            if (!\preg_match(sprintf('/%s/i', $this->schema['pattern']), $subject)) {
                return false;
            }
        }
        return true;
    }
90718
public function validate($subject): bool
    {
        foreach ($this->validatorMap as $validatorName => $validatorClass) {
            if (\array_key_exists($validatorName, $this->schema)) {
                /**
                 * @var ValidatorInterface $typeValidator
                 */
                $typeValidator = new $validatorClass($this->schema, $this->rootSchema);
                if (!$typeValidator->validate($subject)) {
                    return false;
                }
            }
        }
        return true;
    }