Comparing version 0.0.37 to 0.0.38
@@ -32,3 +32,3 @@ import { ValidationError, Type, StringType, NumberType, LiteralType, ObjectType, ArrayType, UnionType, PartialType, TupleType, DateType, LazyType, UndefinedType, NullType, EnumType, BooleanType, UnknownType, Literal, ObjectShape, ObjectOptions, AnyType, UnionOptions, PartialOpts, IntersectionResult, DeepPartialShape, PartialShape, Eval, ToUnion, keySignature, StringTypes, OptionalType } from './types'; | ||
}; | ||
export declare const literalUnion: <T extends Literal[]>(...args: T) => UnionType<ToLiteralUnion<T>>; | ||
export declare const literals: <T extends Literal[]>(...args: T) => UnionType<ToLiteralUnion<T>>; | ||
export declare const record: <T extends AnyType>(schema: T) => ObjectType<{ | ||
@@ -35,0 +35,0 @@ [keySignature]: T; |
@@ -17,3 +17,3 @@ "use strict"; | ||
exports.intersection = (l, r) => l.and(r); | ||
exports.literalUnion = (...args) => new types_1.UnionType(args.map(exports.literal)); | ||
exports.literals = (...args) => new types_1.UnionType(args.map(exports.literal)); | ||
exports.record = (schema) => new types_1.ObjectType({ [types_1.keySignature]: schema }); | ||
@@ -20,0 +20,0 @@ exports.dictionary = (schema) => { |
{ | ||
"name": "myzod", | ||
"version": "0.0.37", | ||
"version": "0.0.38", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./libs/index.js", |
@@ -237,4 +237,6 @@ # myzod | ||
##### Literals | ||
```typescript | ||
const schema = myzod.literalUnion('red', 'green', 'blue'); | ||
const schema = myzod.literals('red', 'green', 'blue'); | ||
type Schema = myzod.Infer<typeof schema>; // => 'red' | 'green' | 'blue' | ||
@@ -241,0 +243,0 @@ |
65447
605