Giter Site home page Giter Site logo

Comments (7)

jpotts18 avatar jpotts18 commented on June 15, 2024

The library has changed significantly since this time.

from swiftvalidator.

datomnurdin avatar datomnurdin commented on June 15, 2024

I already state it inside the issue.

from swiftvalidator.

jpotts18 avatar jpotts18 commented on June 15, 2024

Validation Objects have been phased out and replaced with Rules in 2.0

https://github.com/jpotts18/SwiftValidator/blob/master/Validator/PhoneNumberRule.swift

from swiftvalidator.

imothee avatar imothee commented on June 15, 2024

Hi,

This problem still exists even on the code you linked to. What the error is saying is that you are using the if let when there is not an optional type returned.

The valid condition is to not have the if and just use the straight let.

class PhoneNumberRule: Rule {
//    let PHONE_REGEX = "^\\d{3}-\\d{3}-\\d{4}$"
    let PHONE_REGEX = "^\\d{10}$"

    var message:String {
        return "Enter a valid 10 digit phone number"
    }

    func validate(value: String) -> Bool {
        let phoneTest = NSPredicate(format: "SELF MATCHES %@", PHONE_REGEX)
        if phoneTest.evaluateWithObject(value) {
            return true
        }
        return false
    }

    func errorMessage() -> String {
        return message
    }

}

Xcode Version 6.3 (6D570)

from swiftvalidator.

schan93 avatar schan93 commented on June 15, 2024

Can confirm this error. I am also getting this issue.

from swiftvalidator.

datomnurdin avatar datomnurdin commented on June 15, 2024

Please review my pull request here.

#22

from swiftvalidator.

jpotts18 avatar jpotts18 commented on June 15, 2024

Solved with #22 Thanks!

from swiftvalidator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.