Comments (6)
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.
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.
Example:
> canonicalizeEmail $ BS.pack "michael @snoyman.com"
Just "[email protected]"
from email-validate-hs.
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.
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.
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)
- quasiquoter? HOT 3
- Cabal homepage URL is returning a 404 HOT 2
- Consider adding PathPiece instance? HOT 3
- Major version changes (v3) HOT 4
- Add NFData and Binary instances to EmailAddress HOT 2
- Allow testing with doctest-0.15 HOT 4
- Allow testing with hspec-2.5 HOT 1
- Use case-insensitive ByteString in EmailAddress HOT 2
- Quotes-wrapped `Show` intentional? HOT 3
- Zero width characters
- Status of v3 and offer of help HOT 1
- Please relax version constraint on 'template-haskell' to support ghc-8.10.1 HOT 2
- Fail on dotless domain names
- testsuite failing in Stackage Nightly HOT 4
- The package is disabled in Stackage HOT 4
- Create EmailAdress or validate String HOT 1
- canonicalizeEmail removes spaces inside emails HOT 3
- hspec-2.11 not accepted
- bytestring-0.12, template-haskell-2.20, doctest-0.21 not accepted HOT 3
- template-haskell-2.21 not tolerated HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from email-validate-hs.