Validates an objects properties with the given rules.

@param object        $object
@param AllOf[]|array $rules
@param string|null   $group
@param string[]      $messages
@param mixed|null    $default

@return self
505138
public function object($object, array $rules, string $group = null, array $messages = [], $default = null): self
    {
        if (!is_object($object)) {
            throw new InvalidArgumentException('The first argument should be an object');
        }

        foreach ($rules as $property => $options) {
            $this->validateInput(
                $this->getPropertyValue($object, $property, $default),
                new Configuration($options, $property, $group, $default),
                $messages
            );
        }

        return $this;
    }
1334432
public static function fromArray($input, $group = NULL, $object = NULL)
	{
		if (!isset(self::$groups[$group])) {
			throw new \InvalidArgumentException('Group \'' . $group . '\' not supported for ' . 'Skrz\\Meta\\Fixtures\\Protobuf\\ClassWithEmbeddedMessageProperty\\Embedded' . '.');
		} else {
			$id = self::$groups[$group];
		}

		if ($object === null) {
			$object = new Embedded();
		} elseif (!($object instanceof Embedded)) {
			throw new \InvalidArgumentException('You have to pass object of class Skrz\Meta\Fixtures\Protobuf\ClassWithEmbeddedMessageProperty\Embedded.');
		}

		if (($id & 1) > 0 && isset($input['x'])) {
			$object->x = $input['x'];
		} elseif (($id & 1) > 0 && array_key_exists('x', $input) && $input['x'] === null) {
			$object->x = null;
		}

		return $object;
	}
1264971
public static function reset($object)
	{
		if (!($object instanceof MessageOptions)) {
			throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\MessageOptions.');
		}
		$object->messageSetWireFormat = NULL;
		$object->noStandardDescriptorAccessor = NULL;
		$object->deprecated = NULL;
		$object->mapEntry = NULL;
		$object->uninterpretedOption = NULL;
	}
927426
public function propertyNotVal($object, $property, $value, $message = '')
    {
        $this->assertion->setActual($object);

        return $this->assertion->to->not->have->property($property, $value, $message);
    }
527091
protected function validateFilterForObject(array $object, array $filters)
    {
        // Unfortunately, setting the 'calendardata' here is optional. If
        // it was excluded, we actually need another call to get this as
        // well.
        if (!isset($object['calendardata'])) {
            $object = $this->getCalendarObject($object['calendarid'], $object['uri']);
        }

        $vObject = VObject\Reader::read($object['calendardata']);

        $validator = new CalDAV\CalendarQueryValidator();
        $result = $validator->validate($vObject, $filters);

        // Destroy circular references so PHP will GC the object.
        $vObject->destroy();

        return $result;
    }
204119
public function validate(Request $request, array $rules,
                             array $messages = [], array $customAttributes = [])
    {
        return $this->getValidationFactory()->make(
            $request->all(), $rules, $messages, $customAttributes
        )->validate();
    }
775814
public function validate(Request $request, array $rules, array $messages = [], array $customAttributes = [])
    {
        $validator = $this->getValidationFactory()->make($request->all(), $rules, $messages, $customAttributes);

        if ($validator->fails()) {
            $this->throwValidationException($request, $validator);
        }
    }
144876
public function validationRules(array $rules = array())
    {
        if (empty($rules)) {
            return $this->validationRules;
        }

        $this->validationRules = $rules;

        return $this;
    }
906918
protected static function createFromObjectForAdditional($object)
    {
        $indexProperty = null;
        $class = null;

        if (property_exists($object, 'anyOf')) {
            $indexProperty = 'anyOf';
            $class = AnyOf::class;
        } elseif (property_exists($object, 'allOf')) {
            $indexProperty = 'allOf';
            $class = AllOf::class;
        } elseif (property_exists($object, 'oneOf')) {
            $indexProperty = 'oneOf';
            $class = OneOf::class;
        } else {
            return null;
        }

        //Parse index property's object as validator
        foreach ($object->{$indexProperty} as &$property) {
            $property = BaseValidator::createFromObject($property);
        }

        $validator = new $class($object->{$indexProperty});

        return $validator;
    }
431429
public void validate(final Object record, final CsvBindingErrors bindingErrors, 
            final ValidationContext<Object> validationContext, final Class<?>... groups) {
        Objects.requireNonNull(record);
        Objects.requireNonNull(bindingErrors);
        Objects.requireNonNull(validationContext);
        
        processConstraintViolation(getTargetValidator().validate(record, groups), bindingErrors, validationContext);
    }
558416
public function addAll(array $rules): self
    {
        try {
            return $this->add(...$rules);
        } catch (\TypeError $e) {
            throw new \InvalidArgumentException('Only Rule objects are allowed', 0, $e);
        }
    }
242669
public function validateObject($object) {
        if (!$object instanceof SerialisableObject) {
            throw new ClassNotSerialisableException(get_class($object));
        }

        $classAnnotations = ClassAnnotationParser::instance()->parse($object);

        $validationFields = $classAnnotations->getFieldAnnotationsForMatchingTag("validation");

        $validationErrors = array();

        foreach ($validationFields as $field => $annotation) {

            $value = $object->__getSerialisablePropertyValue($field);

            foreach ($annotation[0]->getValues() as $validatorString) {

                $explodedValidator = explode("(", $validatorString);
                $validatorKey = trim($explodedValidator[0]);

                // Gather validator args if supplied.
                $validatorArgs = array();
                if (sizeof($explodedValidator) > 1) {
                    $argsCSV = explode(")", $explodedValidator[1]);
                    $args = explode("|", $argsCSV[0]);

                    foreach ($args as $arg) {
                        $validatorArgs[] = trim($arg);
                    }
                }

                $validator = isset($this->validators[$validatorKey]) ? $this->validators[$validatorKey] : null;
                if (isset($validator)) {
                    $valid = $validator->validateObjectFieldValue($value, $field, $object, $validatorArgs, $validatorKey);

                    if ($valid !== true) {
                        if (!isset($validationErrors[$field])) $validationErrors[$field] = array();
                        $message = preg_replace_callback("/\\$([0-9])/", function ($matches) use ($validatorArgs) {
                            return $validatorArgs[$matches[1] - 1];
                        }, $validator->getValidationMessage());
                        $validationErrors[$field][$validatorKey] = new FieldValidationError($field, $validatorKey, $message);
                    }

                } else {
                    throw new InvalidValidatorException($validatorKey, $field, $object);
                }


            }

        }

        return $validationErrors;


    }
1254064
public function getMessage($rule, $default = NULL)
    {
        $messages = $this->getMessages();
        if (isset($messages[$rule])) {
            return $messages[$rule];
        } else {
            return $default;
        }
    }
1152875
protected function performValidation($rules = [])
    {
        $validation = $this->makeValidator($rules);

        $result = $validation->passes();

        $this->setErrors($validation->messages());

        return $result;
    }
1050392
public function isValid($group_name, $object = null)
    {
        if (false === $this->isValidGroup($group_name)) {
            throw new InvalidArgumentException("$group_name is not a valid cache validator group.");
        }

        $is_valid = true;
        foreach ($this->validators[$group_name] as $validator) {
            if (false === $validator->isValid($object)) {
                $is_valid = false;
                break;
            }
        }

        return $is_valid;
    }
760144
protected function validate($object): void
    {
        $needType = $this->type();

        if (!$object instanceof $needType) {
            throw new \InvalidArgumentException("Element " . get_class($object) . " must be instance of " . $needType);
        }
    }
906252
public function validate(array $params, array $rules, array $messages = [])
    {
        $validator = app(Validator::class)->make($params, $rules, $messages);

        if ($validator->fails()) {
            throw new ValidationException(
                $validator, new JsonResponse($validator->errors()->getMessages(), 422)
            );
        }
    }