protected function validateValue($key, $value) { if (self::isValidValue($value)) { if ($this->schema) { if ($this->schema->has($key)) { $schema_value = $this->schema->get($key); if (!Schema::isValidType($value, $schema_value)) { throw new InvalidValueException("Data has a value at `" . $key . "` which is not of the expected type."); } } else { throw new InvalidKeyException("Data has a key `" . $key . "` that is not in the schema."); } } } else { throw new InvalidValueException("Value at key `" . $key . "` is not valid."); } }