February 12, 2020
After having fun with building Claritas, I knew I want to publish more packages. Claritas is very simple and doing just one job (darkens or lightern colors) but looks like 79 people (at the time of writing it) were interested to download it. It’s 78 more than I expected :) (that makes me happy! :))
what is age_guard?
AgeGuard verifies if a person born at a given date meets provided age requirements. I needed this functionality at my daily work and I couldn’t find anything simple and suitable to my needs, so I built it.
It checks given DOB (date of birth) against given age. Useful when registering users.
Acceptable formats of DOB (mix of integers and strings):
- (1, 12, 2020)
- (01, 03, 2010)
- (“01”, “12”, “2020”)
- (“1”, “3”, “2010”)
- (“03”, “March”, “2011”)
- (“17”, “Mar”, “2018”)
- (17, “Mar”, 2019)
- (“13”, 02, “2019”)
Also it does some dates validations (dates from the future are rejected).
Installation
The package can be installed by adding age_guard to your list of dependencies in mix.exs:
def deps do
[
{:age_guard, "~> 0.1.0"}
]
end
Basic Usage
AgeGuard.is_old_enough?(day_of_birth, month_of_birth, year_of_birth, required_age)
Examples:
iex> AgeGuard.is_old_enough?("1","5","2019", 21)
false
iex> AgeGuard.is_old_enough?(3, "March", 2000, 21)
false
iex> AgeGuard.is_old_enough?(3, 3, 2000, 18)
true
iex> AgeGuard.is_old_enough?(3, "Dec", 1995, 18)
true