Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

default validation error string convertibles #494

Merged
merged 5 commits into from
Aug 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 12 additions & 2 deletions Sources/Vapor/Validation/Error.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@

Will be caught automatically by ValidationMiddleware
*/
public protocol ValidationErrorProtocol: Swift.Error {
public protocol ValidationErrorProtocol: Swift.Error, CustomStringConvertible, CustomDebugStringConvertible {
/**
Description of what went wrong
*/
var message: String { get }

/**
Description of what went wrong
Description of Validator that failed
*/
var validatorDescription: String { get }

Expand All @@ -22,6 +22,16 @@ public protocol ValidationErrorProtocol: Swift.Error {
var inputDescription: String { get }
}

extension ValidationErrorProtocol {
public var description: String {
return "[\(inputDescription)] \(validatorDescription) - \(message)"
}

public var debugDescription: String {
return description
}
}

/**
When a validation fails, usually passed through this protocol from

Expand Down