https://github.com/rafalgolarz/age_guard
Verifies if a person born at a given date meets provided age requirements.
https://github.com/rafalgolarz/age_guard
age-verification-gate elixir elixir-lang hex package
Last synced: 12 months ago
JSON representation
Verifies if a person born at a given date meets provided age requirements.
- Host: GitHub
- URL: https://github.com/rafalgolarz/age_guard
- Owner: rafalgolarz
- License: mit
- Created: 2020-02-11T23:16:52.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-10T14:41:20.000Z (over 6 years ago)
- Last Synced: 2025-06-05T07:45:58.982Z (about 1 year ago)
- Topics: age-verification-gate, elixir, elixir-lang, hex, package
- Language: Elixir
- Homepage: https://hex.pm/packages/age_guard
- Size: 93.8 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.txt
Awesome Lists containing this project
README
[](https://hex.pm/packages/age_guard)
[](https://hex.pm/packages/age_guard)
# AgeGuard
Verifies if a person born at a given date meets provided age requirements.
It checks given DOB (date of birth) against given age.
Useful when registering users.
Acceptable formats of DOB (mix of integers and strings):
```Elixir
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 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`:
```elixir
def deps do
[
{:age_guard, "~> 0.1.0"}
]
end
```
and running `mix deps.get` in your console to fetch from Hex.
## Basic Usage
```Elixir
AgeGuard.is_old_enough?(day_of_birth, month_of_birth, year_of_birth, required_age)
```
Examples:
```Elixir
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
```
## Author
Rafał Golarz
AgeGuard is released under the [MIT License](https://github.com/rafalgolarz/age_guard/blob/master/LICENSE.txt).