-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Samppa Saarela <samppa.saarela@iki.fi>
- Loading branch information
Showing
15 changed files
with
1,105 additions
and
4 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,38 @@ | ||
{ | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest All", | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": ["--runInBand"], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"timeout": 20000 | ||
}, | ||
{ | ||
"type": "node", | ||
"request": "launch", | ||
"name": "Jest Current File", | ||
"program": "${workspaceFolder}/node_modules/.bin/jest", | ||
"args": ["${relativeFile}"], | ||
"console": "integratedTerminal", | ||
"internalConsoleOptions": "neverOpen", | ||
"timeout": 20000 | ||
}, | ||
{ | ||
"name": "Run Current file", | ||
"type": "node", | ||
"request": "launch", | ||
"runtimeExecutable": "node", | ||
"runtimeArgs": ["--nolazy", "-r", "${workspaceFolder}/node_modules/ts-node/register/transpile-only"], | ||
|
||
"args": ["${relativeFile}"], | ||
|
||
"cwd": "${workspaceRoot}", | ||
"internalConsoleOptions": "openOnSessionStart", | ||
"skipFiles": ["<node_internals>/**", "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
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
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,3 @@ | ||
src | ||
tsconfig.json | ||
tsconfig.tsbuildinfo |
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,4 @@ | ||
# Change Log | ||
|
||
All notable changes to this project will be documented in this file. | ||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. |
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,43 @@ | ||
[![npm version](https://badge.fury.io/js/%40finnair%2Fv-validation-luxon.svg)](https://badge.fury.io/js/%40finnair%2Fv-validation-luxon) | ||
|
||
# v-validation-luxon | ||
|
||
`@finnair/v-validation-luxon` is an extension to `@finnair/v-validation`. | ||
|
||
`Vluxon` extension uses custom wrapper types for Luxon DateTime to support full JSON roundtrip with strict validation. | ||
|
||
[Documentation for `v-validation`](https://github.com/finnair/v-validation). | ||
|
||
## Getting Started | ||
|
||
Install v-validation using [`yarn`](https://yarnpkg.com/en/package/jest): | ||
|
||
```bash | ||
yarn add @finnair/v-validation-luxon | ||
``` | ||
|
||
Or [`npm`](https://www.npmjs.com/): | ||
|
||
```bash | ||
npm install @finnair/v-validation-luxon | ||
``` | ||
|
||
## Vluxon | ||
|
||
`validateLuxon` functions can be used to build custom DateTime validators/converters | ||
by supplying a RegExp pattern and a wrapper class (subclass of LuxonDateTime). | ||
The wrapper class should guarantee proper `toJSON()` and other required properties | ||
for the type (e.g. timezone handling). | ||
|
||
Time zone 00:00 is serialized as `Z`. | ||
|
||
| Vluxon . | Format | Description | | ||
| ----------------- | -------------------------- | ------------------------------------------------------ | | ||
| date | `YYYY-MM-DD` | Local date. | | ||
| dateUtc | `YYYY-MM-DD` | Date in UTC time zone. | | ||
| dateTime | `YYYY-MM-DDTHH:mm:ssZ` | Date and time in local (parsed) time zone. | | ||
| dateTimeUtc | `YYYY-MM-DDTHH:mm:ssZ` | Date and time in UTC time zone. | | ||
| dateTimeMillis | `YYYY-MM-DDTHH:mm:ss.SSSZ` | Date and time with millis in local (parsed) time zone. | | ||
| dateTimeMillisUtc | `YYYY-MM-DDTHH:mm:ss.SSSZ` | Date and time with millis in UTC time zone. | | ||
| time | `HH:mm:ss` | Local time. | | ||
| duration | ISO 8601 Duration | Luxon `Duration` with pattern validation. | |
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,35 @@ | ||
{ | ||
"name": "@finnair/v-validation-luxon", | ||
"version": "1.0.1", | ||
"private": false, | ||
"description": "Luxon validators", | ||
"main": "dist/index.js", | ||
"types": "dist/index.d.ts", | ||
"license": "MIT", | ||
"homepage": "https://github.com/finnair/v-validation/tree/master/packages/luxon#readme", | ||
"bugs": "https://github.com/finnair/v-validation/issues", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/finnair/v-validation.git", | ||
"directory": "packages/luxon" | ||
}, | ||
"keywords": [ | ||
"validation", | ||
"validate", | ||
"convert", | ||
"normalize", | ||
"typescript", | ||
"luxon" | ||
], | ||
"scripts": { | ||
"build": "tsc -b ." | ||
}, | ||
"dependencies": { | ||
"@finnair/path": "^1.0.1", | ||
"@finnair/v-validation": "^1.0.1", | ||
"luxon": "3.0.1" | ||
}, | ||
"devDependencies": { | ||
"@types/luxon": "3.0.0" | ||
} | ||
} |
Oops, something went wrong.