Comparing version 1.9.2 to 1.10.0
@@ -367,3 +367,3 @@ import { keySignature } from './index'; | ||
}; | ||
export declare class EnumType<T> extends Type<ValueOf<T>> implements Defaultable<ValueOf<T>> { | ||
export declare class EnumType<T> extends Type<ValueOf<T>> implements Defaultable<ValueOf<T>>, WithPredicate<ValueOf<T>> { | ||
private readonly enumeration; | ||
@@ -373,2 +373,3 @@ private values; | ||
private readonly coerceOpt?; | ||
private readonly predicates; | ||
constructor(enumeration: T, opts?: EnumOptions<T>); | ||
@@ -380,2 +381,4 @@ parse(value?: unknown): ValueOf<T>; | ||
coerce(opt: EnumCoerceOptions): EnumType<T>; | ||
enum(): T; | ||
withPredicate(fn: (value: ValueOf<T>) => boolean, errMsg?: ErrMsg<ValueOf<T>> | undefined): this; | ||
} | ||
@@ -382,0 +385,0 @@ type DeepPartial<T> = { |
@@ -1207,2 +1207,3 @@ "use strict"; | ||
this.values = Object.values(enumeration); | ||
this.predicates = null; | ||
this.coerceOpt = opts.coerce; | ||
@@ -1225,2 +1226,5 @@ this.defaultValue = opts.defaultValue; | ||
} | ||
if (this.predicates) { | ||
applyPredicates(this.predicates, coercedValue); | ||
} | ||
return coercedValue; | ||
@@ -1240,2 +1244,8 @@ } | ||
} | ||
enum() { | ||
return this.enumeration; | ||
} | ||
withPredicate(fn, errMsg) { | ||
return withPredicate(this, { func: fn, errMsg }); | ||
} | ||
} | ||
@@ -1242,0 +1252,0 @@ exports.EnumType = EnumType; |
{ | ||
"name": "myzod", | ||
"version": "1.9.2", | ||
"version": "1.10.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./libs/index.js", |
111903
1944