Git Product home page Git Product logo

Comments (6)

Porges avatar Porges commented on June 12, 2024

Unfortunately this is a legitimate email address.

I think that stripping whitespace & comments should be permitted by the spec, so I'm thinking of doing that by default - very few people will need access to that information.

I have an experimental version that I can upload to GitHub in an hour or so.

By the way, I presume that you're using ByteStrings internally? If I swap out Parsec for Attoparsec I will also be able to drop the dependency on 'ranges'.

from email-validate-hs.

Porges avatar Porges commented on June 12, 2024

I've committed the experimental version in a new branch: d6083cb

Changes are:

  • Attoparsec is now the dependency instead of Parsec - ByteStrings are now the input
  • EmailAddress is now an abstract type, emailAddress is its smart constructor
  • comments and whitespace are dropped from the input email as it is parsed into an EmailAddress
  • there is a utility method canonicalizeEmail that will give you an email as a ByteString without comments or whitespace (if it is valid)
  • the Ranges dependency has been removed

Please let me know if this suits your use case, or if the dependency on Attoparsec is problematic. In the mean time I'm going make a proper test suite before I merge this back in. This will be a new major version as it is backwards-incompatible.

from email-validate-hs.

Porges avatar Porges commented on June 12, 2024

Example:

 > canonicalizeEmail $ BS.pack "michael @snoyman.com"
Just "[email protected]"

from email-validate-hs.

snoyberg avatar snoyberg commented on June 12, 2024

This seems to work perfectly, thanks! FWIW, I'm actually using Text, not ByteString, but I can handle character encoding issues.

Thank you for getting this patch out so quickly.

from email-validate-hs.

Porges avatar Porges commented on June 12, 2024

Yes, I'm using ByteString instead of Text to indicate that it's ASCII. It also avoids putting a dependency on Text. (For the benefit of anyone else who might read this: you'll need to convert it using decodeUtf8.)

There should really be a separate type for this purpose...

I'm not sure if you found it already, but this version is on Hackage as email-validate-1.0.0.

from email-validate-hs.

snoyberg avatar snoyberg commented on June 12, 2024

Yep, I've found it and am already using it :).

Yes, the age-old ASCII issue. I tried to address this once with an Ascii newtype wrapper, but it was such a pain and there was so much pushback that I gave up and I just do exactly what you did here.

from email-validate-hs.

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.