-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 393190e
Showing
18 changed files
with
2,654 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Elm CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- "main" | ||
pull_request: | ||
|
||
jobs: | ||
main: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Read .nvmrc | ||
run: echo NVMRC=`cat .nvmrc` >> $GITHUB_ENV | ||
- uses: actions/setup-node@v2 | ||
with: | ||
node-version: ${{ env.NVMRC }} | ||
cache: yarn | ||
|
||
# Re-use node_modules between runs until package.json or yarn.lock changes. | ||
- name: Cache node_modules | ||
id: cache-node_modules | ||
uses: actions/cache@v2 | ||
with: | ||
path: node_modules | ||
key: node_modules-${{ hashFiles('package.json', 'yarn.lock') }} | ||
|
||
# Re-use ~/.elm between runs until elm.json, elm-tooling.json or | ||
# review/elm.json changes. The Elm compiler saves downloaded Elm packages | ||
# to ~/.elm, and elm-tooling saves downloaded tool executables there. | ||
- name: Cache ~/.elm | ||
uses: actions/cache@v2 | ||
with: | ||
path: ~/.elm | ||
key: elm-${{ hashFiles('elm.json', 'elm-tooling.json', 'review/elm.json') }} | ||
|
||
# Install tools from elm-tooling.json, unless we restored them from | ||
# cache. yarn.lock and elm-tooling.json can change independently, | ||
# so we need to install separately based on what was restored from cache. | ||
# This is run even if we restored ~/.elm from cache to be 100% sure | ||
# node_modules/.bin/ contains links to all your tools. `elm-tooling | ||
# install` runs very fast when there’s nothing new to download so | ||
# skipping the step doesn’t save much time. | ||
- name: yarn ci install | ||
run: yarn install --immutable --immutable-cache --check-cache | ||
|
||
- name: elm make | ||
run: npx --no-install elm make src/Main.elm --output=/dev/null | ||
|
||
- name: elm-test | ||
run: yarn test | ||
|
||
- name: elm-review | ||
run: yarn review | ||
|
||
- name: elm-format | ||
run: npx --no-install elm-format --validate src tests | ||
|
||
- name: build | ||
run: npm run build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
elm-stuff/ | ||
node_modules/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lts/gallium |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright © 2024 Scrive AB | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Elm Personal Number | ||
|
||
[](https://github.com/scrive/elm-personal-number/actions) | ||
|
||
A library for validating personal numbers. Built from the ground up using parser combinators! | ||
|
||
## Supported countries | ||
|
||
- Swedish personal numbers (personnummer). | ||
- Swedish personal numbers for foreign visitors (sammordningsnummer). | ||
- Norwegian personal numbers (fødselsnummer). | ||
- Finnish personal numbers (henkilötunnus). | ||
- Danish personal numbers (personnummer). | ||
|
||
## Example usage | ||
|
||
```elm | ||
import PersonalNumber.Swedish as PersonalNumber exposing (ValidationError(..)) | ||
|
||
|
||
personalNumber : String -> String | ||
personalNumber str = | ||
case PersonalNumber.fromString str of | ||
Ok pnr -> | ||
-- The `pnr` is wrapped in a `PersonalNumber` type and is | ||
-- guaranteed to be valid. Use the `display` function to turn | ||
-- it back into a user readable string. | ||
PersonalNumber.display pnr | ||
|
||
Err InvalidFormat -> | ||
"Not the correct format for a swedish personal number." | ||
|
||
Err InvalidLength -> | ||
"The personal number is not of the correct length." | ||
|
||
Err InvalidDate -> | ||
"The first part of the personal number needs to be a valid date." | ||
|
||
Err InvalidChecksum -> | ||
"One or more digits in the personal number is wrong." | ||
``` | ||
|
||
## JSON | ||
|
||
```elm | ||
import PersonalNumber.Swedish as PersonalNumber | ||
import Json.Decode as Decode | ||
import Json.Encode as Encode | ||
|
||
type alias Person = | ||
{ personalNumber : PersonalNumber.PersonalNumber | ||
} | ||
|
||
decoder : Decoder Person | ||
decoder = | ||
Decode.map2 Person | ||
(Decode.field "personal_number" PersonalNumber.decoder) | ||
|
||
|
||
encode : Person -> Value | ||
encode person = | ||
Encode.object | ||
[ ( "personal_number", PersonalNumber.encode person.personalNumber ) | ||
] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"tools": { | ||
"elm": "0.19.1", | ||
"elm-format": "0.8.7", | ||
"elm-json": "0.2.10", | ||
"elm-test-rs": "3.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"type": "package", | ||
"name": "scrive/elm-personal-number", | ||
"summary": "A library for validating personal numbers", | ||
"license": "MIT", | ||
"version": "1.0.0", | ||
"source-directories": [ | ||
"src" | ||
], | ||
"exposed-modules": [ | ||
"PersonalNumber.Danish", | ||
"PersonalNumber.Finnish", | ||
"PersonalNumber.Norwegian", | ||
"PersonalNumber.Swedish" | ||
], | ||
"elm-version": "0.19.0 <= v < 0.20.0", | ||
"dependencies": { | ||
"elm/core": "1.0.2 <= v < 2.0.0", | ||
"elm/json": "1.1.2 <= v < 2.0.0", | ||
"elm/parser": "1.1.0 <= v < 2.0.0", | ||
"elmcraft/core-extra": "2.0.0 <= v < 3.0.0" | ||
}, | ||
"test-dependencies": { | ||
"elm-explorations/test": "2.0.0 <= v < 3.0.0" | ||
} | ||
} |
Oops, something went wrong.