@valbuild/core 0.63.5 → 0.63.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/declarations/src/index.d.ts +1 -0
- package/dist/declarations/src/initSchema.d.ts +3 -0
- package/dist/declarations/src/schema/date.d.ts +38 -0
- package/dist/declarations/src/schema/index.d.ts +2 -1
- package/dist/{index-7c62e0da.cjs.prod.js → index-041f75bd.cjs.prod.js} +112 -1
- package/dist/{index-3388fb33.cjs.dev.js → index-c67ed8f9.cjs.dev.js} +112 -1
- package/dist/{index-3c8b4776.esm.js → index-fccba617.esm.js} +112 -2
- package/dist/valbuild-core.cjs.dev.js +2 -1
- package/dist/valbuild-core.cjs.prod.js +2 -1
- package/dist/valbuild-core.esm.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.dev.js +1 -1
- package/expr/dist/valbuild-core-expr.cjs.prod.js +1 -1
- package/expr/dist/valbuild-core-expr.esm.js +1 -1
- package/package.json +1 -1
- package/patch/dist/valbuild-core-patch.cjs.dev.js +1 -1
- package/patch/dist/valbuild-core-patch.cjs.prod.js +1 -1
- package/patch/dist/valbuild-core-patch.esm.js +2 -2
@@ -40,6 +40,7 @@ export { type SerializedNumberSchema, NumberSchema } from "./schema/number.js";
|
|
40
40
|
export { type SerializedBooleanSchema, BooleanSchema } from "./schema/boolean.js";
|
41
41
|
export { type SerializedImageSchema, ImageSchema } from "./schema/image.js";
|
42
42
|
export { type SerializedFileSchema, FileSchema } from "./schema/file.js";
|
43
|
+
export { type SerializedDateSchema, DateSchema } from "./schema/date.js";
|
43
44
|
export { type SerializedRichTextSchema, RichTextSchema, } from "./schema/richtext.js";
|
44
45
|
export { type SerializedUnionSchema, UnionSchema } from "./schema/union.js";
|
45
46
|
export { type SerializedLiteralSchema, LiteralSchema } from "./schema/literal.js";
|
@@ -10,6 +10,7 @@ import { literal } from "./schema/literal.js";
|
|
10
10
|
import { keyOf } from "./schema/keyOf.js";
|
11
11
|
import { record } from "./schema/record.js";
|
12
12
|
import { file } from "./schema/file.js";
|
13
|
+
import { date } from "./schema/date.js";
|
13
14
|
export type InitSchema = {
|
14
15
|
readonly string: typeof string;
|
15
16
|
readonly boolean: typeof boolean;
|
@@ -23,6 +24,7 @@ export type InitSchema = {
|
|
23
24
|
readonly keyOf: typeof keyOf;
|
24
25
|
readonly record: typeof record;
|
25
26
|
readonly file: typeof file;
|
27
|
+
readonly date: typeof date;
|
26
28
|
};
|
27
29
|
export declare function initSchema(): {
|
28
30
|
string: <T extends string>(options?: Record<string, never> | undefined) => import("./schema/string.js").StringSchema<T>;
|
@@ -80,4 +82,5 @@ export declare function initSchema(): {
|
|
80
82
|
keyOf: <Src extends import("./selector/index.js").GenericSelector<import("./source/index.js").SourceObject | import("./source/index.js").SourceArray, undefined> & import("./module.js").ValModuleBrand>(valModule: Src) => import("./schema/index.js").Schema<Src extends import("./selector/index.js").GenericSelector<infer S_2 extends import("./source/index.js").Source, undefined> ? S_2 extends readonly import("./source/index.js").Source[] ? number : S_2 extends import("./source/index.js").SourceObject ? string extends keyof S_2 ? import("./schema/string.js").RawString : keyof S_2 : S_2 extends Record<string, import("./source/index.js").Source> ? import("./schema/string.js").RawString : never : never>;
|
81
83
|
record: <S_3 extends import("./schema/index.js").Schema<import("./selector/index.js").SelectorSource>>(schema: S_3) => import("./schema/index.js").Schema<Record<string, import("./schema/index.js").SelectorOfSchema<S_3>>>;
|
82
84
|
file: (options?: import("./schema/file.js").FileOptions | undefined) => import("./schema/index.js").Schema<import("./index.js").FileSource<import("./schema/file.js").FileMetadata>>;
|
85
|
+
date: <T_3 extends string>(options?: Record<string, never> | undefined) => import("./schema/date.js").DateSchema<T_3>;
|
83
86
|
};
|
@@ -0,0 +1,38 @@
|
|
1
|
+
import { Schema, SerializedSchema } from "./index.js";
|
2
|
+
import { SourcePath } from "../val/index.js";
|
3
|
+
import { ValidationErrors } from "./validation/ValidationError.js";
|
4
|
+
type DateOptions = {
|
5
|
+
/**
|
6
|
+
* Validate that the date is this date or after (inclusive).
|
7
|
+
*
|
8
|
+
* @example
|
9
|
+
* 2021-01-01
|
10
|
+
*/
|
11
|
+
from?: string;
|
12
|
+
/**
|
13
|
+
* Validate that the date is this date or before (inclusive).
|
14
|
+
*
|
15
|
+
* @example
|
16
|
+
* 2021-01-01
|
17
|
+
*/
|
18
|
+
to?: string;
|
19
|
+
};
|
20
|
+
export type SerializedDateSchema = {
|
21
|
+
type: "date";
|
22
|
+
options?: DateOptions;
|
23
|
+
opt: boolean;
|
24
|
+
};
|
25
|
+
export declare class DateSchema<Src extends string | null> extends Schema<Src> {
|
26
|
+
readonly options?: DateOptions | undefined;
|
27
|
+
readonly opt: boolean;
|
28
|
+
private readonly isRaw;
|
29
|
+
constructor(options?: DateOptions | undefined, opt?: boolean, isRaw?: boolean);
|
30
|
+
validate(path: SourcePath, src: Src): ValidationErrors;
|
31
|
+
assert(src: Src): boolean;
|
32
|
+
from(from: string): DateSchema<Src>;
|
33
|
+
to(to: string): DateSchema<Src>;
|
34
|
+
nullable(): DateSchema<Src | null>;
|
35
|
+
serialize(): SerializedSchema;
|
36
|
+
}
|
37
|
+
export declare const date: <T extends string>(options?: Record<string, never>) => DateSchema<T>;
|
38
|
+
export {};
|
@@ -12,8 +12,9 @@ import { SerializedRecordSchema } from "./record.js";
|
|
12
12
|
import { SerializedRichTextSchema } from "./richtext.js";
|
13
13
|
import { SerializedStringSchema } from "./string.js";
|
14
14
|
import { SerializedUnionSchema } from "./union.js";
|
15
|
+
import { SerializedDateSchema } from "./date.js";
|
15
16
|
import { ValidationErrors } from "./validation/ValidationError.js";
|
16
|
-
export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedFileSchema | SerializedImageSchema;
|
17
|
+
export type SerializedSchema = SerializedStringSchema | SerializedLiteralSchema | SerializedBooleanSchema | SerializedNumberSchema | SerializedObjectSchema | SerializedArraySchema | SerializedUnionSchema | SerializedRichTextSchema | SerializedRecordSchema | SerializedKeyOfSchema | SerializedFileSchema | SerializedDateSchema | SerializedImageSchema;
|
17
18
|
export declare abstract class Schema<Src extends SelectorSource> {
|
18
19
|
abstract validate(path: SourcePath, src: Src): ValidationErrors;
|
19
20
|
abstract assert(src: Src): boolean;
|
@@ -2587,6 +2587,113 @@ var keyOf = function keyOf(valModule) {
|
|
2587
2587
|
return new KeyOfSchema(valModule === null || valModule === void 0 || (_valModule$GetSchema = valModule[GetSchema$1]) === null || _valModule$GetSchema === void 0 ? void 0 : _valModule$GetSchema.serialize(), getValPath(valModule));
|
2588
2588
|
};
|
2589
2589
|
|
2590
|
+
var DateSchema = /*#__PURE__*/function (_Schema) {
|
2591
|
+
_inherits(DateSchema, _Schema);
|
2592
|
+
function DateSchema(options) {
|
2593
|
+
var _this;
|
2594
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2595
|
+
var isRaw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
2596
|
+
_classCallCheck(this, DateSchema);
|
2597
|
+
_this = _callSuper(this, DateSchema);
|
2598
|
+
_this.options = options;
|
2599
|
+
_this.opt = opt;
|
2600
|
+
_this.isRaw = isRaw;
|
2601
|
+
return _this;
|
2602
|
+
}
|
2603
|
+
_createClass(DateSchema, [{
|
2604
|
+
key: "validate",
|
2605
|
+
value: function validate(path, src) {
|
2606
|
+
var _this$options, _this$options2, _this$options3, _this$options4;
|
2607
|
+
if (this.opt && (src === null || src === undefined)) {
|
2608
|
+
return false;
|
2609
|
+
}
|
2610
|
+
if (typeof src !== "string") {
|
2611
|
+
return _defineProperty({}, path, [{
|
2612
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
2613
|
+
value: src
|
2614
|
+
}]);
|
2615
|
+
}
|
2616
|
+
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.from && (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.to) {
|
2617
|
+
if (this.options.from > this.options.to) {
|
2618
|
+
return _defineProperty({}, path, [{
|
2619
|
+
message: "From date ".concat(this.options.from, " is after to date ").concat(this.options.to),
|
2620
|
+
value: src,
|
2621
|
+
fatal: true
|
2622
|
+
}]);
|
2623
|
+
}
|
2624
|
+
if (src < this.options.from || src > this.options.to) {
|
2625
|
+
return _defineProperty({}, path, [{
|
2626
|
+
message: "Date is not between ".concat(this.options.from, " and ").concat(this.options.to),
|
2627
|
+
value: src
|
2628
|
+
}]);
|
2629
|
+
}
|
2630
|
+
} else if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.from) {
|
2631
|
+
if (src < this.options.from) {
|
2632
|
+
return _defineProperty({}, path, [{
|
2633
|
+
message: "Date is before the minimum date ".concat(this.options.from),
|
2634
|
+
value: src
|
2635
|
+
}]);
|
2636
|
+
}
|
2637
|
+
} else if ((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.to) {
|
2638
|
+
if (src > this.options.to) {
|
2639
|
+
return _defineProperty({}, path, [{
|
2640
|
+
message: "Date is after the maximum date ".concat(this.options.to),
|
2641
|
+
value: src
|
2642
|
+
}]);
|
2643
|
+
}
|
2644
|
+
}
|
2645
|
+
// const errors = [];
|
2646
|
+
|
2647
|
+
// if (errors.length > 0) {
|
2648
|
+
// return {
|
2649
|
+
// [path]: errors,
|
2650
|
+
// } as ValidationErrors;
|
2651
|
+
// }
|
2652
|
+
return false;
|
2653
|
+
}
|
2654
|
+
}, {
|
2655
|
+
key: "assert",
|
2656
|
+
value: function assert(src) {
|
2657
|
+
if (this.opt && (src === null || src === undefined)) {
|
2658
|
+
return true;
|
2659
|
+
}
|
2660
|
+
return typeof src === "string";
|
2661
|
+
}
|
2662
|
+
}, {
|
2663
|
+
key: "from",
|
2664
|
+
value: function from(_from) {
|
2665
|
+
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
2666
|
+
from: _from
|
2667
|
+
}), this.opt, this.isRaw);
|
2668
|
+
}
|
2669
|
+
}, {
|
2670
|
+
key: "to",
|
2671
|
+
value: function to(_to) {
|
2672
|
+
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
2673
|
+
to: _to
|
2674
|
+
}), this.opt, this.isRaw);
|
2675
|
+
}
|
2676
|
+
}, {
|
2677
|
+
key: "nullable",
|
2678
|
+
value: function nullable() {
|
2679
|
+
return new DateSchema(this.options, true, this.isRaw);
|
2680
|
+
}
|
2681
|
+
}, {
|
2682
|
+
key: "serialize",
|
2683
|
+
value: function serialize() {
|
2684
|
+
return {
|
2685
|
+
type: "date",
|
2686
|
+
opt: this.opt,
|
2687
|
+
options: this.options
|
2688
|
+
};
|
2689
|
+
}
|
2690
|
+
}]);
|
2691
|
+
return DateSchema;
|
2692
|
+
}(Schema);
|
2693
|
+
var date = function date(options) {
|
2694
|
+
return new DateSchema(options);
|
2695
|
+
};
|
2696
|
+
|
2590
2697
|
// import type { F } from "ts-toolbelt";
|
2591
2698
|
// import { i18n, I18n } from "./schema/future/i18n";
|
2592
2699
|
// import { oneOf } from "./schema/future/oneOf";
|
@@ -2609,7 +2716,8 @@ function initSchema() {
|
|
2609
2716
|
literal: literal,
|
2610
2717
|
keyOf: keyOf,
|
2611
2718
|
record: record,
|
2612
|
-
file: file
|
2719
|
+
file: file,
|
2720
|
+
date: date
|
2613
2721
|
// i18n: i18n(locales),
|
2614
2722
|
};
|
2615
2723
|
}
|
@@ -3563,6 +3671,8 @@ function deserializeSchema(serialized) {
|
|
3563
3671
|
return new FileSchema(serialized.options, serialized.opt);
|
3564
3672
|
case "image":
|
3565
3673
|
return new ImageSchema(serialized.options, serialized.opt);
|
3674
|
+
case "date":
|
3675
|
+
return new DateSchema(serialized.options);
|
3566
3676
|
default:
|
3567
3677
|
{
|
3568
3678
|
var exhaustiveCheck = serialized;
|
@@ -4303,6 +4413,7 @@ function tryJsonParse(str) {
|
|
4303
4413
|
exports.ArraySchema = ArraySchema;
|
4304
4414
|
exports.BooleanSchema = BooleanSchema;
|
4305
4415
|
exports.Call = Call;
|
4416
|
+
exports.DateSchema = DateSchema;
|
4306
4417
|
exports.Expr = Expr;
|
4307
4418
|
exports.FATAL_ERROR_TYPES = FATAL_ERROR_TYPES;
|
4308
4419
|
exports.FILE_REF_PROP = FILE_REF_PROP;
|
@@ -2587,6 +2587,113 @@ var keyOf = function keyOf(valModule) {
|
|
2587
2587
|
return new KeyOfSchema(valModule === null || valModule === void 0 || (_valModule$GetSchema = valModule[GetSchema$1]) === null || _valModule$GetSchema === void 0 ? void 0 : _valModule$GetSchema.serialize(), getValPath(valModule));
|
2588
2588
|
};
|
2589
2589
|
|
2590
|
+
var DateSchema = /*#__PURE__*/function (_Schema) {
|
2591
|
+
_inherits(DateSchema, _Schema);
|
2592
|
+
function DateSchema(options) {
|
2593
|
+
var _this;
|
2594
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2595
|
+
var isRaw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
2596
|
+
_classCallCheck(this, DateSchema);
|
2597
|
+
_this = _callSuper(this, DateSchema);
|
2598
|
+
_this.options = options;
|
2599
|
+
_this.opt = opt;
|
2600
|
+
_this.isRaw = isRaw;
|
2601
|
+
return _this;
|
2602
|
+
}
|
2603
|
+
_createClass(DateSchema, [{
|
2604
|
+
key: "validate",
|
2605
|
+
value: function validate(path, src) {
|
2606
|
+
var _this$options, _this$options2, _this$options3, _this$options4;
|
2607
|
+
if (this.opt && (src === null || src === undefined)) {
|
2608
|
+
return false;
|
2609
|
+
}
|
2610
|
+
if (typeof src !== "string") {
|
2611
|
+
return _defineProperty({}, path, [{
|
2612
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
2613
|
+
value: src
|
2614
|
+
}]);
|
2615
|
+
}
|
2616
|
+
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.from && (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.to) {
|
2617
|
+
if (this.options.from > this.options.to) {
|
2618
|
+
return _defineProperty({}, path, [{
|
2619
|
+
message: "From date ".concat(this.options.from, " is after to date ").concat(this.options.to),
|
2620
|
+
value: src,
|
2621
|
+
fatal: true
|
2622
|
+
}]);
|
2623
|
+
}
|
2624
|
+
if (src < this.options.from || src > this.options.to) {
|
2625
|
+
return _defineProperty({}, path, [{
|
2626
|
+
message: "Date is not between ".concat(this.options.from, " and ").concat(this.options.to),
|
2627
|
+
value: src
|
2628
|
+
}]);
|
2629
|
+
}
|
2630
|
+
} else if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.from) {
|
2631
|
+
if (src < this.options.from) {
|
2632
|
+
return _defineProperty({}, path, [{
|
2633
|
+
message: "Date is before the minimum date ".concat(this.options.from),
|
2634
|
+
value: src
|
2635
|
+
}]);
|
2636
|
+
}
|
2637
|
+
} else if ((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.to) {
|
2638
|
+
if (src > this.options.to) {
|
2639
|
+
return _defineProperty({}, path, [{
|
2640
|
+
message: "Date is after the maximum date ".concat(this.options.to),
|
2641
|
+
value: src
|
2642
|
+
}]);
|
2643
|
+
}
|
2644
|
+
}
|
2645
|
+
// const errors = [];
|
2646
|
+
|
2647
|
+
// if (errors.length > 0) {
|
2648
|
+
// return {
|
2649
|
+
// [path]: errors,
|
2650
|
+
// } as ValidationErrors;
|
2651
|
+
// }
|
2652
|
+
return false;
|
2653
|
+
}
|
2654
|
+
}, {
|
2655
|
+
key: "assert",
|
2656
|
+
value: function assert(src) {
|
2657
|
+
if (this.opt && (src === null || src === undefined)) {
|
2658
|
+
return true;
|
2659
|
+
}
|
2660
|
+
return typeof src === "string";
|
2661
|
+
}
|
2662
|
+
}, {
|
2663
|
+
key: "from",
|
2664
|
+
value: function from(_from) {
|
2665
|
+
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
2666
|
+
from: _from
|
2667
|
+
}), this.opt, this.isRaw);
|
2668
|
+
}
|
2669
|
+
}, {
|
2670
|
+
key: "to",
|
2671
|
+
value: function to(_to) {
|
2672
|
+
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
2673
|
+
to: _to
|
2674
|
+
}), this.opt, this.isRaw);
|
2675
|
+
}
|
2676
|
+
}, {
|
2677
|
+
key: "nullable",
|
2678
|
+
value: function nullable() {
|
2679
|
+
return new DateSchema(this.options, true, this.isRaw);
|
2680
|
+
}
|
2681
|
+
}, {
|
2682
|
+
key: "serialize",
|
2683
|
+
value: function serialize() {
|
2684
|
+
return {
|
2685
|
+
type: "date",
|
2686
|
+
opt: this.opt,
|
2687
|
+
options: this.options
|
2688
|
+
};
|
2689
|
+
}
|
2690
|
+
}]);
|
2691
|
+
return DateSchema;
|
2692
|
+
}(Schema);
|
2693
|
+
var date = function date(options) {
|
2694
|
+
return new DateSchema(options);
|
2695
|
+
};
|
2696
|
+
|
2590
2697
|
// import type { F } from "ts-toolbelt";
|
2591
2698
|
// import { i18n, I18n } from "./schema/future/i18n";
|
2592
2699
|
// import { oneOf } from "./schema/future/oneOf";
|
@@ -2609,7 +2716,8 @@ function initSchema() {
|
|
2609
2716
|
literal: literal,
|
2610
2717
|
keyOf: keyOf,
|
2611
2718
|
record: record,
|
2612
|
-
file: file
|
2719
|
+
file: file,
|
2720
|
+
date: date
|
2613
2721
|
// i18n: i18n(locales),
|
2614
2722
|
};
|
2615
2723
|
}
|
@@ -3563,6 +3671,8 @@ function deserializeSchema(serialized) {
|
|
3563
3671
|
return new FileSchema(serialized.options, serialized.opt);
|
3564
3672
|
case "image":
|
3565
3673
|
return new ImageSchema(serialized.options, serialized.opt);
|
3674
|
+
case "date":
|
3675
|
+
return new DateSchema(serialized.options);
|
3566
3676
|
default:
|
3567
3677
|
{
|
3568
3678
|
var exhaustiveCheck = serialized;
|
@@ -4303,6 +4413,7 @@ function tryJsonParse(str) {
|
|
4303
4413
|
exports.ArraySchema = ArraySchema;
|
4304
4414
|
exports.BooleanSchema = BooleanSchema;
|
4305
4415
|
exports.Call = Call;
|
4416
|
+
exports.DateSchema = DateSchema;
|
4306
4417
|
exports.Expr = Expr;
|
4307
4418
|
exports.FATAL_ERROR_TYPES = FATAL_ERROR_TYPES;
|
4308
4419
|
exports.FILE_REF_PROP = FILE_REF_PROP;
|
@@ -2565,6 +2565,113 @@ var keyOf = function keyOf(valModule) {
|
|
2565
2565
|
return new KeyOfSchema(valModule === null || valModule === void 0 || (_valModule$GetSchema = valModule[GetSchema$1]) === null || _valModule$GetSchema === void 0 ? void 0 : _valModule$GetSchema.serialize(), getValPath(valModule));
|
2566
2566
|
};
|
2567
2567
|
|
2568
|
+
var DateSchema = /*#__PURE__*/function (_Schema) {
|
2569
|
+
_inherits(DateSchema, _Schema);
|
2570
|
+
function DateSchema(options) {
|
2571
|
+
var _this;
|
2572
|
+
var opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
2573
|
+
var isRaw = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
2574
|
+
_classCallCheck(this, DateSchema);
|
2575
|
+
_this = _callSuper(this, DateSchema);
|
2576
|
+
_this.options = options;
|
2577
|
+
_this.opt = opt;
|
2578
|
+
_this.isRaw = isRaw;
|
2579
|
+
return _this;
|
2580
|
+
}
|
2581
|
+
_createClass(DateSchema, [{
|
2582
|
+
key: "validate",
|
2583
|
+
value: function validate(path, src) {
|
2584
|
+
var _this$options, _this$options2, _this$options3, _this$options4;
|
2585
|
+
if (this.opt && (src === null || src === undefined)) {
|
2586
|
+
return false;
|
2587
|
+
}
|
2588
|
+
if (typeof src !== "string") {
|
2589
|
+
return _defineProperty({}, path, [{
|
2590
|
+
message: "Expected 'string', got '".concat(_typeof(src), "'"),
|
2591
|
+
value: src
|
2592
|
+
}]);
|
2593
|
+
}
|
2594
|
+
if ((_this$options = this.options) !== null && _this$options !== void 0 && _this$options.from && (_this$options2 = this.options) !== null && _this$options2 !== void 0 && _this$options2.to) {
|
2595
|
+
if (this.options.from > this.options.to) {
|
2596
|
+
return _defineProperty({}, path, [{
|
2597
|
+
message: "From date ".concat(this.options.from, " is after to date ").concat(this.options.to),
|
2598
|
+
value: src,
|
2599
|
+
fatal: true
|
2600
|
+
}]);
|
2601
|
+
}
|
2602
|
+
if (src < this.options.from || src > this.options.to) {
|
2603
|
+
return _defineProperty({}, path, [{
|
2604
|
+
message: "Date is not between ".concat(this.options.from, " and ").concat(this.options.to),
|
2605
|
+
value: src
|
2606
|
+
}]);
|
2607
|
+
}
|
2608
|
+
} else if ((_this$options3 = this.options) !== null && _this$options3 !== void 0 && _this$options3.from) {
|
2609
|
+
if (src < this.options.from) {
|
2610
|
+
return _defineProperty({}, path, [{
|
2611
|
+
message: "Date is before the minimum date ".concat(this.options.from),
|
2612
|
+
value: src
|
2613
|
+
}]);
|
2614
|
+
}
|
2615
|
+
} else if ((_this$options4 = this.options) !== null && _this$options4 !== void 0 && _this$options4.to) {
|
2616
|
+
if (src > this.options.to) {
|
2617
|
+
return _defineProperty({}, path, [{
|
2618
|
+
message: "Date is after the maximum date ".concat(this.options.to),
|
2619
|
+
value: src
|
2620
|
+
}]);
|
2621
|
+
}
|
2622
|
+
}
|
2623
|
+
// const errors = [];
|
2624
|
+
|
2625
|
+
// if (errors.length > 0) {
|
2626
|
+
// return {
|
2627
|
+
// [path]: errors,
|
2628
|
+
// } as ValidationErrors;
|
2629
|
+
// }
|
2630
|
+
return false;
|
2631
|
+
}
|
2632
|
+
}, {
|
2633
|
+
key: "assert",
|
2634
|
+
value: function assert(src) {
|
2635
|
+
if (this.opt && (src === null || src === undefined)) {
|
2636
|
+
return true;
|
2637
|
+
}
|
2638
|
+
return typeof src === "string";
|
2639
|
+
}
|
2640
|
+
}, {
|
2641
|
+
key: "from",
|
2642
|
+
value: function from(_from) {
|
2643
|
+
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
2644
|
+
from: _from
|
2645
|
+
}), this.opt, this.isRaw);
|
2646
|
+
}
|
2647
|
+
}, {
|
2648
|
+
key: "to",
|
2649
|
+
value: function to(_to) {
|
2650
|
+
return new DateSchema(_objectSpread2(_objectSpread2({}, this.options), {}, {
|
2651
|
+
to: _to
|
2652
|
+
}), this.opt, this.isRaw);
|
2653
|
+
}
|
2654
|
+
}, {
|
2655
|
+
key: "nullable",
|
2656
|
+
value: function nullable() {
|
2657
|
+
return new DateSchema(this.options, true, this.isRaw);
|
2658
|
+
}
|
2659
|
+
}, {
|
2660
|
+
key: "serialize",
|
2661
|
+
value: function serialize() {
|
2662
|
+
return {
|
2663
|
+
type: "date",
|
2664
|
+
opt: this.opt,
|
2665
|
+
options: this.options
|
2666
|
+
};
|
2667
|
+
}
|
2668
|
+
}]);
|
2669
|
+
return DateSchema;
|
2670
|
+
}(Schema);
|
2671
|
+
var date = function date(options) {
|
2672
|
+
return new DateSchema(options);
|
2673
|
+
};
|
2674
|
+
|
2568
2675
|
// import type { F } from "ts-toolbelt";
|
2569
2676
|
// import { i18n, I18n } from "./schema/future/i18n";
|
2570
2677
|
// import { oneOf } from "./schema/future/oneOf";
|
@@ -2587,7 +2694,8 @@ function initSchema() {
|
|
2587
2694
|
literal: literal,
|
2588
2695
|
keyOf: keyOf,
|
2589
2696
|
record: record,
|
2590
|
-
file: file
|
2697
|
+
file: file,
|
2698
|
+
date: date
|
2591
2699
|
// i18n: i18n(locales),
|
2592
2700
|
};
|
2593
2701
|
}
|
@@ -3541,6 +3649,8 @@ function deserializeSchema(serialized) {
|
|
3541
3649
|
return new FileSchema(serialized.options, serialized.opt);
|
3542
3650
|
case "image":
|
3543
3651
|
return new ImageSchema(serialized.options, serialized.opt);
|
3652
|
+
case "date":
|
3653
|
+
return new DateSchema(serialized.options);
|
3544
3654
|
default:
|
3545
3655
|
{
|
3546
3656
|
var exhaustiveCheck = serialized;
|
@@ -4278,4 +4388,4 @@ function tryJsonParse(str) {
|
|
4278
4388
|
}
|
4279
4389
|
}
|
4280
4390
|
|
4281
|
-
export { ArraySchema as A, BooleanSchema as B, Call as C, Expr as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, LiteralSchema as L, NilSym as N, ObjectSchema as O, PatchError as P, RT_IMAGE_TAG as R, StringLiteral as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, StringTemplate as e, Sym as f, evaluate as g, initVal as h, index as i, Schema as j, FILE_REF_PROP as k, FILE_REF_SUBTYPE_TAG as l, modules as m, derefPatch as n, RecordSchema as o, parse$1 as p, StringSchema as q, NumberSchema as r, splitModuleFilePathAndModulePath as s, ImageSchema as t, FileSchema as u, RichTextSchema as v, deserializeSchema as w, ValApi as x };
|
4391
|
+
export { ArraySchema as A, BooleanSchema as B, Call as C, DateSchema as D, Expr as E, FATAL_ERROR_TYPES as F, GenericSelector as G, Internal as I, LiteralSchema as L, NilSym as N, ObjectSchema as O, PatchError as P, RT_IMAGE_TAG as R, StringLiteral as S, UnionSchema as U, VAL_EXTENSION as V, _typeof as _, _slicedToArray as a, _createClass as b, _classCallCheck as c, _toConsumableArray as d, StringTemplate as e, Sym as f, evaluate as g, initVal as h, index as i, Schema as j, FILE_REF_PROP as k, FILE_REF_SUBTYPE_TAG as l, modules as m, derefPatch as n, RecordSchema as o, parse$1 as p, StringSchema as q, NumberSchema as r, splitModuleFilePathAndModulePath as s, ImageSchema as t, FileSchema as u, RichTextSchema as v, deserializeSchema as w, ValApi as x };
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('./index-c67ed8f9.cjs.dev.js');
|
6
6
|
require('./result-48320acd.cjs.dev.js');
|
7
7
|
require('marked');
|
8
8
|
require('@valbuild/core');
|
@@ -11,6 +11,7 @@ require('@valbuild/core');
|
|
11
11
|
|
12
12
|
exports.ArraySchema = expr_dist_valbuildCoreExpr.ArraySchema;
|
13
13
|
exports.BooleanSchema = expr_dist_valbuildCoreExpr.BooleanSchema;
|
14
|
+
exports.DateSchema = expr_dist_valbuildCoreExpr.DateSchema;
|
14
15
|
exports.FATAL_ERROR_TYPES = expr_dist_valbuildCoreExpr.FATAL_ERROR_TYPES;
|
15
16
|
exports.FILE_REF_PROP = expr_dist_valbuildCoreExpr.FILE_REF_PROP;
|
16
17
|
exports.FILE_REF_SUBTYPE_TAG = expr_dist_valbuildCoreExpr.FILE_REF_SUBTYPE_TAG;
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('./index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('./index-041f75bd.cjs.prod.js');
|
6
6
|
require('./result-26f67b40.cjs.prod.js');
|
7
7
|
require('marked');
|
8
8
|
require('@valbuild/core');
|
@@ -11,6 +11,7 @@ require('@valbuild/core');
|
|
11
11
|
|
12
12
|
exports.ArraySchema = expr_dist_valbuildCoreExpr.ArraySchema;
|
13
13
|
exports.BooleanSchema = expr_dist_valbuildCoreExpr.BooleanSchema;
|
14
|
+
exports.DateSchema = expr_dist_valbuildCoreExpr.DateSchema;
|
14
15
|
exports.FATAL_ERROR_TYPES = expr_dist_valbuildCoreExpr.FATAL_ERROR_TYPES;
|
15
16
|
exports.FILE_REF_PROP = expr_dist_valbuildCoreExpr.FILE_REF_PROP;
|
16
17
|
exports.FILE_REF_SUBTYPE_TAG = expr_dist_valbuildCoreExpr.FILE_REF_SUBTYPE_TAG;
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { A as ArraySchema, B as BooleanSchema, F as FATAL_ERROR_TYPES, k as FILE_REF_PROP, l as FILE_REF_SUBTYPE_TAG, u as FileSchema, G as GenericSelector, t as ImageSchema, I as Internal, L as LiteralSchema, r as NumberSchema, O as ObjectSchema, R as RT_IMAGE_TAG, o as RecordSchema, v as RichTextSchema, j as Schema, q as StringSchema, U as UnionSchema, V as VAL_EXTENSION, x as ValApi, n as derefPatch, w as deserializeSchema, i as expr, h as initVal, m as modules } from './index-
|
1
|
+
export { A as ArraySchema, B as BooleanSchema, D as DateSchema, F as FATAL_ERROR_TYPES, k as FILE_REF_PROP, l as FILE_REF_SUBTYPE_TAG, u as FileSchema, G as GenericSelector, t as ImageSchema, I as Internal, L as LiteralSchema, r as NumberSchema, O as ObjectSchema, R as RT_IMAGE_TAG, o as RecordSchema, v as RichTextSchema, j as Schema, q as StringSchema, U as UnionSchema, V as VAL_EXTENSION, x as ValApi, n as derefPatch, w as deserializeSchema, i as expr, h as initVal, m as modules } from './index-fccba617.esm.js';
|
2
2
|
import './result-a8316efa.esm.js';
|
3
3
|
import 'marked';
|
4
4
|
import '@valbuild/core';
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-c67ed8f9.cjs.dev.js');
|
6
6
|
require('../../dist/result-48320acd.cjs.dev.js');
|
7
7
|
require('marked');
|
8
8
|
require('@valbuild/core');
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-041f75bd.cjs.prod.js');
|
6
6
|
require('../../dist/result-26f67b40.cjs.prod.js');
|
7
7
|
require('marked');
|
8
8
|
require('@valbuild/core');
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export { C as Call, E as Expr, N as NilSym, S as StringLiteral, e as StringTemplate, f as Sym, g as evaluate, p as parse } from '../../dist/index-
|
1
|
+
export { C as Call, E as Expr, N as NilSym, S as StringLiteral, e as StringTemplate, f as Sym, g as evaluate, p as parse } from '../../dist/index-fccba617.esm.js';
|
2
2
|
import '../../dist/result-a8316efa.esm.js';
|
3
3
|
import 'marked';
|
4
4
|
import '@valbuild/core';
|
package/package.json
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-c67ed8f9.cjs.dev.js');
|
6
6
|
var result = require('../../dist/result-48320acd.cjs.dev.js');
|
7
7
|
var util = require('../../dist/util-b213092b.cjs.dev.js');
|
8
8
|
require('marked');
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
4
4
|
|
5
|
-
var expr_dist_valbuildCoreExpr = require('../../dist/index-
|
5
|
+
var expr_dist_valbuildCoreExpr = require('../../dist/index-041f75bd.cjs.prod.js');
|
6
6
|
var result = require('../../dist/result-26f67b40.cjs.prod.js');
|
7
7
|
var util = require('../../dist/util-030d8a1f.cjs.prod.js');
|
8
8
|
require('marked');
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-
|
2
|
-
export { P as PatchError } from '../../dist/index-
|
1
|
+
import { _ as _typeof, a as _slicedToArray, P as PatchError, s as splitModuleFilePathAndModulePath, b as _createClass, c as _classCallCheck, d as _toConsumableArray } from '../../dist/index-fccba617.esm.js';
|
2
|
+
export { P as PatchError } from '../../dist/index-fccba617.esm.js';
|
3
3
|
import { f as isNonEmpty, e as err, o as ok, m as map, g as flatMap, i as isErr, h as flatMapReduce, j as filterOrElse, k as mapErr, l as map$1, n as all, p as flatten, q as allT } from '../../dist/result-a8316efa.esm.js';
|
4
4
|
import { p as pipe } from '../../dist/util-18613e99.esm.js';
|
5
5
|
import 'marked';
|