Validation Vapor 2 Valid-Type throws & ldquo; Use of undeclared type Valid & rdquo;


I try to use the Vapor 2 Valid Type, but the compiler only say: "Use of undeclared type Valid".

I had read: +

In my my Package.swift I have defined

  • /vapor/vapor.git
  • /vapor/validation-provider.git
  • /fluent-provider.git

as dependencies.

If I try to use Valid<SomeValidator> the compiler says: "Use of undeclared type Valid".

The use of import Validation vs import VaporValidation makes no difference.

Does any one have an idea how I can get Valid to work?

THX for your help.

Edit: I created a new Vapor project vapor new validtest --api.

Edited the Package.swift:

import PackageDescription

let package = Package(
    name: "validtest",
    targets: [
        Target(name: "App"),
        Target(name: "Run", dependencies: ["App"]),
    dependencies: [
        .Package(url: "", majorVersion: 2),
        .Package(url: "", majorVersion: 1),
        .Package(url: "", majorVersion: 1),
        .Package(url: "", majorVersion: 1)
    exclude: [

Ran vapor fetch and vapor xcode.

In Routes.swift from the example code I tryed this:

import Vapor
import FluentProvider
import Validation
// or and both imports are tested
import VaporValidation

extension Droplet {
    func setupRoutes() throws {
        get("info") { req in

            let input: Valid<OnlyAlphanumeric> = try["input"].validated()

No matter which import I used, the compiler always say: "Use of undeclared type Valid".

Instead of

let input: Valid<OnlyAlphanumeric> = try["input"].validated()

Vapor 2's validation uses

guard let input =["input"]?.string else { throw SomeError }
try input.validated(by: OnlyAlphanumeric())

If the input string is not valid, a ValidationError will be thrown.