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

Fixed bug with passedValidation property #40

Merged
merged 6 commits into from
Dec 17, 2020
Merged

Conversation

bdrelling
Copy link
Contributor

Description
passedValidation should be true so long as the incoming/submitted email is in a valid syntax/format. If it isn't, it should actually throw an error. Previously, this was returning false if it had no autocorrect suggestion, which was incorrect logic.

@bdrelling bdrelling requested a review from a team as a code owner December 17, 2020 19:16
@khaptonstall khaptonstall self-assigned this Dec 17, 2020
Sources/SpotHeroEmailValidator/SHValidationResult.swift Outdated Show resolved Hide resolved
var closestDistance = Int.max

// TODO: Use better name for arrayString parameter
for arrayString in array {
let distance = Int(string.levenshteinDistance(from: arrayString))

if distance < closestDistance && Float(distance) / Float(string.count) < tolerance {
if distance < closestDistance, Float(distance) / Float(string.count) < tolerance {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just a preference change? (Personally like boolean operators checks like this, so just wondering).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a SwiftFormat thing based on the rules we have defined.

bdrelling and others added 2 commits December 17, 2020 13:27
Co-authored-by: Kyle Haptonstall <khaptonstall@users.noreply.github.com>
@objc public let passedValidation: Bool

/// The autocorrect suggestion to be applied. Nil if there no suggestion.
@objc public let autocorrectSuggestion: String?

@objc public init(passedValidation: Bool, autocorrectSuggestion: String?) {
Copy link

@github-actions github-actions bot Dec 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Attributes should be on their own lines in functions and types, but on the same line as variables and imports.
attributes SHValidationResult.swift:12

@github-actions
Copy link

1 Error
🚫 SwiftLint found 1 violations.
2 Messages
📖 Formatted with SwiftFormat v0.47.8.
📖 Linted with SwiftLint v0.41.0.

Generated by 🚫 Danger

@bdrelling bdrelling merged commit cc668fa into master Dec 17, 2020
@bdrelling bdrelling deleted the fix-validation branch December 17, 2020 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants