I was inspired by validator.js that I’ve used a lot in javascript. I didn’t find anything similar in Julia, so I started developing validator.jl. I think that this could be useful considering also the expansion of Julia.
So I’m here to ask you what do you think and if this could be useful.
I’ve just begun the development and it will be a long journey. If anyone is interested in contributing please do!
don’t use non-const globals, also there’s already:
help?> isascii("123")
isascii(c::Union{AbstractChar,AbstractString}) -> Bool
Test whether a character belongs to the ASCII character set, or whether this is true for all elements of a string.
Examples
≡≡≡≡≡≡≡≡≡≡
julia> isascii('a')
true
julia> isascii('α')
false
julia> isascii("abc")
true
julia> isascii("αβγ")
false
You also need to make your pkg named Validator.jl.
Thanks for pointing out ascii function and for pointing out non-const global regex declared.
This package is inspired from validator.js so I’m trying to port all functionality, isAfter included. Not sure why it was added in validator.js but I don’t think it is a bad idea to include it. What do you think?
Julia is very much not Javascript and the community has a strong opposition against stuff close to “single function package” on the spectrum. If all the functions are just utilities that can be done in Base Julia, idiomatically, I personally don’t think it’s worth making a package.
But this is not to say I want to stop you, it’s totally fine, but at the same time, I don’t think people want Julia packages to be like Javascript in terms of organization and functionality fragmentation.
What’s the benefit of copy-paste if there is a library to do that? I agree there are some use-cases when you just need a simple function. Not all Julia fields (thinking of data science) needs something like this. But thinking for example about web dev things change. As a web dev I don’t think there is a single project where I didnd’t use any validators (not talking just about email validation).
It could be that it has no value, that’s why I’m trying to understand all your ideas.
validator.js has more than 6 million weekly downloads, so it seems to be used in js world (that of course could be totally different from Julia, that’s why I’m asking).
It’s funny to read about license plate cause I’ve recently worked on a computer vision project where plate validation was needed.
In general more code is always good. But I’m not sure the scope of the package makes a lot of sense. What exactly is it validating? Every possible string format? Social security numbers? License plates? That is way too broad a scope for a package.
Some minor comments
Stylistically, modules are usually CamelCase, and functions are snake_case in Julia (or lower case in one word)
There is already an isascii and isempty in Julia Base for strings. Having another, different implementation is confusing.
Be careful of string indexing like you do in isBIC.jl - it can throw errors if the input is not ASCII strings. Instead, use functions like nextind, or validate the string is ASCII before indexing. You can read more in the Julia documentation on strings.