Skip to content

Commit

Permalink
feat: Support for Luxon
Browse files Browse the repository at this point in the history
  • Loading branch information
ssaarela authored Aug 29, 2022
1 parent edff4ec commit 94b3806
Show file tree
Hide file tree
Showing 30 changed files with 1,933 additions and 41 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/code_coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ name: Code Coverage
# events but only for the master branch
on:
push:
branches: [ master ]
branches: [master]
pull_request:
branches: [ master ]
branches: [master]

jobs:
build:
runs-on: [ubuntu-latest]
timeout-minutes: 5
steps:
- uses: actions/checkout@master
- run: yarn
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/continuous_integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
matrix:
node: ['12', '14', '16']
name: Node ${{ matrix.node }} sample
timeout-minutes: 5
steps:
- uses: actions/checkout@v2
- name: Setup node
Expand Down
38 changes: 38 additions & 0 deletions .vscode/launch.json
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/**"]
}
]
}
107 changes: 107 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,113 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.1.0-alpha.9](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.8...v1.1.0-alpha.9) (2022-08-19)

**Note:** Version bump only for package v-validation





# [1.1.0-alpha.8](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.7...v1.1.0-alpha.8) (2022-08-19)

**Note:** Version bump only for package v-validation





# [1.1.0-alpha.7](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.6...v1.1.0-alpha.7) (2022-08-18)

**Note:** Version bump only for package v-validation





# [1.1.0-alpha.6](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.6) (2022-08-17)


### Bug Fixes

* Fix exports ([b9eacb6](https://github.com/finnair/v-validation/commit/b9eacb6e98a05a07049eb0a8f97b7e6b4958973a))


### Features

* fromISO helper for Luxon wrapper construction ([e3b8f24](https://github.com/finnair/v-validation/commit/e3b8f247b3a9bfef8ad474688f995862fdd810e3))
* Support for Luxon ([00d0a8e](https://github.com/finnair/v-validation/commit/00d0a8e8c8de46bfeb3502f51bb8cd5a3627070e))





# [1.1.0-alpha.5](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.5) (2022-08-16)


### Bug Fixes

* Fix exports ([904e63c](https://github.com/finnair/v-validation/commit/904e63c4a40e65d274349ae0f5ea80c697c5c8ce))


### Features

* fromISO helper for Luxon wrapper construction ([81d5b2e](https://github.com/finnair/v-validation/commit/81d5b2eb08f360ab56ec0c6caece392a0e6eb1a1))
* Support for Luxon ([6a243f0](https://github.com/finnair/v-validation/commit/6a243f043db2ca6700180eb758a08d8edfe1e538))





# [1.1.0-alpha.4](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.3...v1.1.0-alpha.4) (2022-08-15)

**Note:** Version bump only for package v-validation





# [1.1.0-alpha.3](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.2...v1.1.0-alpha.3) (2022-08-15)

**Note:** Version bump only for package v-validation





# [1.1.0-alpha.2](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.1...v1.1.0-alpha.2) (2022-08-12)


### Bug Fixes

* Fix exports ([c4c42f7](https://github.com/finnair/v-validation/commit/c4c42f715e8c52b29b76f7f07753f632528a69ab))





# [1.1.0-alpha.1](https://github.com/finnair/v-validation/compare/v1.1.0-alpha.0...v1.1.0-alpha.1) (2022-08-12)


### Features

* fromISO helper for Luxon wrapper construction ([187796e](https://github.com/finnair/v-validation/commit/187796e707f44033d94943ef64d48626317b4d80))





# [1.1.0-alpha.0](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.0) (2022-08-12)


### Features

* Support for Luxon ([6f982df](https://github.com/finnair/v-validation/commit/6f982df9b55395e953069914c93fef677dec171e))





## [1.0.1](https://github.com/finnair/v-validation/compare/v0.9.1...v1.0.1) (2022-01-20)

### Features
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,16 @@ conform to the expected model.

[`@finnair/v-validation` README](./packages/core/README.md)

## Vluxon

`Vluxon` contains `v-validation` extensions for [Luxon](https://moment.github.io/luxon/).

[`@finnair/v-validation-luxon` README](./packages/luxon/README.md)

## Vmoment

NOTE: [Moment is a legacy project in maintenance mode](https://momentjs.com/docs/#/-project-status/).

`Vmoment` contains `v-validation` extensions for [Moment.js](https://momentjs.com/).

[`@finnair/v-validation-moment` README](./packages/moment/README.md)
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.0.1",
"version": "1.1.0-alpha.9",
"npmClient": "yarn",
"useWorkspaces": true
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"lerna": "4.0.0",
"prettier": "2.0.5",
"ts-jest": "27.1.3",
"ts-node": "10.9.1",
"typescript": "4.5.4"
},
"workspaces": {
Expand Down
24 changes: 24 additions & 0 deletions packages/core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,30 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.

# [1.1.0-alpha.6](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.6) (2022-08-17)

**Note:** Version bump only for package @finnair/v-validation





# [1.1.0-alpha.5](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.5) (2022-08-16)

**Note:** Version bump only for package @finnair/v-validation





# [1.1.0-alpha.0](https://github.com/finnair/v-validation/compare/v1.0.1...v1.1.0-alpha.0) (2022-08-12)

**Note:** Version bump only for package @finnair/v-validation





## [1.0.1](https://github.com/finnair/v-validation/compare/v0.9.1...v1.0.1) (2022-01-20)

### Features
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@finnair/v-validation",
"version": "1.0.1",
"version": "1.1.0-alpha.6",
"private": false,
"description": "V-validation core package",
"main": "dist/index.js",
Expand All @@ -24,7 +24,7 @@
"build": "tsc -b ."
},
"dependencies": {
"@finnair/path": "^1.0.1",
"@finnair/path": "^1.1.0-alpha.6",
"@types/deep-equal": "1.0.1",
"@types/uuid-validate": "0.0.1",
"deep-equal": "2.0.5",
Expand Down
12 changes: 9 additions & 3 deletions packages/core/src/V.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,12 @@ describe('ValidationResult', () => {
});
});

test('assertTrue', () =>
expectValid(
true,
V.assertTrue(value => value === true),
));

describe('strings', () => {
test('valid value', () => {
expectValid('str', V.string());
Expand Down Expand Up @@ -359,9 +365,9 @@ describe('objects', () => {
test('disallow all properties', () =>
expectViolations({ property: 'value' }, V.object({ additionalProperties: false }), defaultViolations.unknownPropertyDenied(ROOT.property('property'))));

test('non-object not allowed', () => {
expectViolations('string', V.object({}), defaultViolations.object(ROOT));
});
test('string not allowed', () => expectViolations('string', V.object({}), defaultViolations.object(ROOT)));

test('number not allowed', () => expectViolations(123, V.object({}), defaultViolations.object()));

test('parent may disallow additional properties for child models', async () => {
const validator = V.object({ extends: { additionalProperties: false }, additionalProperties: true });
Expand Down
8 changes: 4 additions & 4 deletions packages/core/src/validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -271,9 +271,9 @@ export const defaultViolations = {
oneOf: (matches: number, path: Path = ROOT) => new OneOfMismatch(path, matches),
pattern: (pattern: RegExp, invalidValue: any, path: Path = ROOT) => new PatternViolation(path, '' + pattern, invalidValue),
enum: (name: string, invalidValue: any, path: Path = ROOT) => new EnumMismatch(path, name, invalidValue),
unknownProperty: (path: Path = ROOT) => new Violation(path, ValidatorType.UnknownProperty),
unknownPropertyDenied: (path: Path = ROOT) => new Violation(path, ValidatorType.UnknownPropertyDenied),
cycle: (path: Path = ROOT) => new Violation(path, 'Cycle'),
unknownProperty: (path: Path) => new Violation(path, ValidatorType.UnknownProperty),
unknownPropertyDenied: (path: Path) => new Violation(path, ValidatorType.UnknownPropertyDenied),
cycle: (path: Path) => new Violation(path, 'Cycle'),
};

export interface AssertTrue {
Expand Down Expand Up @@ -1181,7 +1181,7 @@ export class EnumValidator extends Validator {
export class AssertTrueValidator extends Validator {
private fn: AssertTrue;

constructor(fn: AssertTrue, public readonly type: string = 'AssertTrue', public readonly path?: Path) {
constructor(fn: AssertTrue, public readonly type: string, public readonly path?: Path) {
super();
this.fn = fn;
}
Expand Down
3 changes: 3 additions & 0 deletions packages/luxon/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
src
tsconfig.json
tsconfig.tsbuildinfo
Loading

0 comments on commit 94b3806

Please sign in to comment.