@finnair/v-validation-luxon
Advanced tools
Comparing version 2.0.0 to 3.0.0-alpha.0
@@ -6,2 +6,13 @@ # Change Log | ||
# [3.0.0-alpha.0](https://github.com/finnair/v-validation/compare/v2.0.0...v3.0.0-alpha.0) (2022-09-26) | ||
### Features | ||
* Use SyncPromise also in schema and luxon ([e8590b8](https://github.com/finnair/v-validation/commit/e8590b8c2a44ad28fde88f8682f53628ecf74a0f)) | ||
# [2.0.0](https://github.com/finnair/v-validation/compare/v1.1.0...v2.0.0) (2022-09-08) | ||
@@ -8,0 +19,0 @@ |
@@ -15,3 +15,3 @@ import { ValidationContext, Validator, ValidationResult } from '@finnair/v-validation'; | ||
} | ||
export declare function validateLuxon({ value, path, ctx, type, proto, pattern, parser }: ValidateLuxonParams): Promise<ValidationResult>; | ||
export declare function validateLuxon({ value, path, ctx, type, proto, pattern, parser }: ValidateLuxonParams): PromiseLike<ValidationResult>; | ||
declare function localDate(options?: DateTimeOptions): import("@finnair/v-validation").ValidatorFnWrapper; | ||
@@ -18,0 +18,0 @@ declare function localTime(options?: DateTimeOptions): import("@finnair/v-validation").ValidatorFnWrapper; |
@@ -17,28 +17,26 @@ "use strict"; | ||
function validateLuxon({ value, path, ctx, type, proto, pattern, parser }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
if ((0, v_validation_1.isNullOrUndefined)(value)) { | ||
return ctx.failure(v_validation_1.defaultViolations.notNull(path), value); | ||
if ((0, v_validation_1.isNullOrUndefined)(value)) { | ||
return ctx.failurePromise(v_validation_1.defaultViolations.notNull(path), value); | ||
} | ||
if (proto && value instanceof proto) { | ||
return ctx.successPromise(value); | ||
} | ||
else if (luxon_1.DateTime.isDateTime(value)) { | ||
if (value.isValid) { | ||
return success(value); | ||
} | ||
if (proto && value instanceof proto) { | ||
return ctx.success(value); | ||
} | ||
else if (luxon_1.DateTime.isDateTime(value)) { | ||
if (value.isValid) { | ||
return success(value); | ||
} | ||
else if ((0, v_validation_1.isString)(value)) { | ||
const match = pattern.exec(value); | ||
if (match) { | ||
const dateTime = parser(value, match); | ||
if (dateTime.isValid) { | ||
return success(dateTime); | ||
} | ||
} | ||
else if ((0, v_validation_1.isString)(value)) { | ||
const match = pattern.exec(value); | ||
if (match) { | ||
const dateTime = parser(value, match); | ||
if (dateTime.isValid) { | ||
return success(dateTime); | ||
} | ||
} | ||
} | ||
return ctx.failure(v_validation_1.defaultViolations.date(value, path, type), value); | ||
function success(dateTime) { | ||
return ctx.success(proto ? new proto(dateTime) : dateTime); | ||
} | ||
}); | ||
} | ||
return ctx.failurePromise(v_validation_1.defaultViolations.date(value, path, type), value); | ||
function success(dateTime) { | ||
return ctx.successPromise(proto ? new proto(dateTime) : dateTime); | ||
} | ||
} | ||
@@ -45,0 +43,0 @@ exports.validateLuxon = validateLuxon; |
{ | ||
"name": "@finnair/v-validation-luxon", | ||
"version": "2.0.0", | ||
"version": "3.0.0-alpha.0", | ||
"private": false, | ||
@@ -29,3 +29,3 @@ "description": "Luxon validators", | ||
"@finnair/path": "^2.0.0", | ||
"@finnair/v-validation": "^2.0.0", | ||
"@finnair/v-validation": "^3.0.0-alpha.0", | ||
"luxon": "3.0.3" | ||
@@ -36,3 +36,3 @@ }, | ||
}, | ||
"gitHead": "432759665b664859d5ed80e4b573432abdb23afc" | ||
"gitHead": "f41f76dbe0365314dc15c07d3db2ad5a7b5e4109" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
40487
652
1
+ Added@finnair/path@3.1.0(transitive)
+ Added@finnair/v-validation@3.1.0(transitive)
- Removed@finnair/v-validation@2.0.0(transitive)