Skip to content

Commit

Permalink
tests to deno
Browse files Browse the repository at this point in the history
  • Loading branch information
wilmveel committed Nov 2, 2020
1 parent 29fc52c commit 1a952b3
Show file tree
Hide file tree
Showing 48 changed files with 6,321 additions and 529 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: deno

on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: denolib/setup-deno@v2
with:
deno-version: v1.4.6
- run: |
deno --version
deno test test/index.ts
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<a href="https://opensource.org/licenses/MIT" rel="nofollow"><img src="https://img.shields.io/github/license/vriad/zod" alt="License"></a>
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/npm/dw/zod.svg" alt="npm"></a>
<a href="https://www.npmjs.com/package/zod" rel="nofollow"><img src="https://img.shields.io/github/stars/vriad/zod" alt="stars"></a>
<a href="./src/__tests__" rel="nofollow"><img src="./coverage.svg" alt="coverage"></a>
<a href="test" rel="nofollow"><img src="./coverage.svg" alt="coverage"></a>

</p>
<p align="center">
Expand Down
5,522 changes: 5,522 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 0 additions & 8 deletions src/__tests__/codegen.test.ts

This file was deleted.

145 changes: 0 additions & 145 deletions src/__tests__/validations.test.ts

This file was deleted.

3 changes: 2 additions & 1 deletion src/helpers/errorUtil.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export namespace errorUtil {
export type ErrMessage = string | { message?: string };
export const errToObj = (message?: ErrMessage) => (typeof message === 'string' ? { message } : message || {});
export const errToObj = (message?: ErrMessage) =>
typeof message === 'string' ? { message } : message || {};
}
194 changes: 194 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
'use strict';
/* ZOD */
var __createBinding =
(this && this.__createBinding) ||
(Object.create
? function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, {
enumerable: true,
get: function() {
return m[k];
},
});
}
: function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
});
var __exportStar =
(this && this.__exportStar) ||
function(m, exports) {
for (var p in m)
if (p !== 'default' && !Object.prototype.hasOwnProperty.call(exports, p))
__createBinding(exports, m, p);
};
exports.__esModule = true;
exports.output = exports.input = exports.infer = exports.TypeOf = exports.ZodCodeGenerator = exports.ZodParsedType = exports.ZodErrorMap = exports.ZodTypeAny = exports.ZodSchema = exports.Schema = exports.ZodType = exports.ZodNullable = exports.ZodOptional = exports.ZodTransformer = exports.ZodPromise = exports.ZodNativeEnum = exports.ZodEnum = exports.ZodLiteral = exports.ZodLazy = exports.ZodFunction = exports.ZodRecord = exports.ZodTuple = exports.ZodIntersection = exports.ZodUnion = exports.ZodObject = exports.ZodArray = exports.ZodVoid = exports.ZodNever = exports.ZodUnknown = exports.ZodAny = exports.ZodNull = exports.ZodUndefined = exports.ZodDate = exports.ZodBoolean = exports.ZodBigInt = exports.ZodNumber = exports.ZodString = exports.late = exports.codegen = exports.oboolean = exports.onumber = exports.ostring = exports.nullable = exports.optional = exports.transformer = exports[
'instanceof'
] = exports.promise = exports.nativeEnum = exports[
'enum'
] = exports.literal = exports.lazy = exports[
'function'
] = exports.map = exports.record = exports.tuple = exports.intersection = exports.union = exports.object = exports.array = exports[
'void'
] = exports.never = exports.unknown = exports.any = exports[
'null'
] = exports.undefined = exports.date = exports.boolean = exports.bigint = exports.number = exports.string = exports.custom = exports.ZodTypes = exports.ZodTypeDef = void 0;
var string_ts_1 = require('./types/string.ts');
exports.ZodString = string_ts_1.ZodString;
var number_ts_1 = require('./types/number.ts');
exports.ZodNumber = number_ts_1.ZodNumber;
var bigint_ts_1 = require('./types/bigint.ts');
exports.ZodBigInt = bigint_ts_1.ZodBigInt;
var boolean_ts_1 = require('./types/boolean.ts');
exports.ZodBoolean = boolean_ts_1.ZodBoolean;
var date_ts_1 = require('./types/date.ts');
exports.ZodDate = date_ts_1.ZodDate;
var undefined_ts_1 = require('./types/undefined.ts');
exports.ZodUndefined = undefined_ts_1.ZodUndefined;
var null_ts_1 = require('./types/null.ts');
exports.ZodNull = null_ts_1.ZodNull;
var any_ts_1 = require('./types/any.ts');
exports.ZodAny = any_ts_1.ZodAny;
var unknown_ts_1 = require('./types/unknown.ts');
exports.ZodUnknown = unknown_ts_1.ZodUnknown;
var never_ts_1 = require('./types/never.ts');
exports.ZodNever = never_ts_1.ZodNever;
var void_ts_1 = require('./types/void.ts');
exports.ZodVoid = void_ts_1.ZodVoid;
var array_ts_1 = require('./types/array.ts');
exports.ZodArray = array_ts_1.ZodArray;
var object_ts_1 = require('./types/object.ts');
exports.ZodObject = object_ts_1.ZodObject;
var union_ts_1 = require('./types/union.ts');
exports.ZodUnion = union_ts_1.ZodUnion;
var intersection_ts_1 = require('./types/intersection.ts');
exports.ZodIntersection = intersection_ts_1.ZodIntersection;
var tuple_ts_1 = require('./types/tuple.ts');
exports.ZodTuple = tuple_ts_1.ZodTuple;
var record_ts_1 = require('./types/record.ts');
exports.ZodRecord = record_ts_1.ZodRecord;
var map_ts_1 = require('./types/map.ts');
var function_ts_1 = require('./types/function.ts');
exports.ZodFunction = function_ts_1.ZodFunction;
var lazy_ts_1 = require('./types/lazy.ts');
exports.ZodLazy = lazy_ts_1.ZodLazy;
var literal_ts_1 = require('./types/literal.ts');
exports.ZodLiteral = literal_ts_1.ZodLiteral;
var enum_ts_1 = require('./types/enum.ts');
exports.ZodEnum = enum_ts_1.ZodEnum;
var nativeEnum_ts_1 = require('./types/nativeEnum.ts');
exports.ZodNativeEnum = nativeEnum_ts_1.ZodNativeEnum;
var promise_ts_1 = require('./types/promise.ts');
exports.ZodPromise = promise_ts_1.ZodPromise;
var transformer_ts_1 = require('./types/transformer.ts');
exports.ZodTransformer = transformer_ts_1.ZodTransformer;
var optional_ts_1 = require('./types/optional.ts');
exports.ZodOptional = optional_ts_1.ZodOptional;
var nullable_ts_1 = require('./types/nullable.ts');
exports.ZodNullable = nullable_ts_1.ZodNullable;
var base_ts_1 = require('./types/base.ts');
exports.TypeOf = base_ts_1.TypeOf;
exports.infer = base_ts_1.TypeOf;
exports.input = base_ts_1.input;
exports.output = base_ts_1.output;
exports.ZodType = base_ts_1.ZodType;
exports.Schema = base_ts_1.ZodType;
exports.ZodSchema = base_ts_1.ZodType;
exports.ZodTypeAny = base_ts_1.ZodTypeAny;
exports.ZodTypeDef = base_ts_1.ZodTypeDef;
exports.ZodTypes = base_ts_1.ZodTypes;
// export { ZodIssueCode } from './ZodError.ts';
var parser_ts_1 = require('./parser.ts');
exports.ZodParsedType = parser_ts_1.ZodParsedType;
var defaultErrorMap_ts_1 = require('./defaultErrorMap.ts');
exports.ZodErrorMap = defaultErrorMap_ts_1.ZodErrorMap;
var codegen_ts_1 = require('./codegen.ts');
exports.ZodCodeGenerator = codegen_ts_1.ZodCodeGenerator;
var stringType = string_ts_1.ZodString.create;
exports.string = stringType;
var numberType = number_ts_1.ZodNumber.create;
exports.number = numberType;
var bigIntType = bigint_ts_1.ZodBigInt.create;
exports.bigint = bigIntType;
var booleanType = boolean_ts_1.ZodBoolean.create;
exports.boolean = booleanType;
var dateType = date_ts_1.ZodDate.create;
exports.date = dateType;
var undefinedType = undefined_ts_1.ZodUndefined.create;
exports.undefined = undefinedType;
var nullType = null_ts_1.ZodNull.create;
exports['null'] = nullType;
var anyType = any_ts_1.ZodAny.create;
exports.any = anyType;
var unknownType = unknown_ts_1.ZodUnknown.create;
exports.unknown = unknownType;
var neverType = never_ts_1.ZodNever.create;
exports.never = neverType;
var voidType = void_ts_1.ZodVoid.create;
exports['void'] = voidType;
var arrayType = array_ts_1.ZodArray.create;
exports.array = arrayType;
var objectType = object_ts_1.ZodObject.create;
exports.object = objectType;
var unionType = union_ts_1.ZodUnion.create;
exports.union = unionType;
var intersectionType = intersection_ts_1.ZodIntersection.create;
exports.intersection = intersectionType;
var tupleType = tuple_ts_1.ZodTuple.create;
exports.tuple = tupleType;
var recordType = record_ts_1.ZodRecord.create;
exports.record = recordType;
var mapType = map_ts_1.ZodMap.create;
exports.map = mapType;
var functionType = function_ts_1.ZodFunction.create;
exports['function'] = functionType;
var lazyType = lazy_ts_1.ZodLazy.create;
exports.lazy = lazyType;
var literalType = literal_ts_1.ZodLiteral.create;
exports.literal = literalType;
var enumType = enum_ts_1.ZodEnum.create;
exports['enum'] = enumType;
var nativeEnumType = nativeEnum_ts_1.ZodNativeEnum.create;
exports.nativeEnum = nativeEnumType;
var promiseType = promise_ts_1.ZodPromise.create;
exports.promise = promiseType;
var transformerType = transformer_ts_1.ZodTransformer.create;
exports.transformer = transformerType;
var optionalType = optional_ts_1.ZodOptional.create;
exports.optional = optionalType;
var nullableType = nullable_ts_1.ZodNullable.create;
exports.nullable = nullableType;
var ostring = function() {
return stringType().optional();
};
exports.ostring = ostring;
var onumber = function() {
return numberType().optional();
};
exports.onumber = onumber;
var oboolean = function() {
return booleanType().optional();
};
exports.oboolean = oboolean;
var codegen = codegen_ts_1.ZodCodeGenerator.create;
exports.codegen = codegen;
exports.custom = function(check, params) {
return anyType().refine(check, params);
};
var instanceOfType = function(cls, params) {
if (params === void 0) {
params = {
message: 'Input not instance of ' + cls.name,
};
}
return exports.custom(function(data) {
return data instanceof cls;
}, params);
};
exports['instanceof'] = instanceOfType;
exports.late = {
object: object_ts_1.ZodObject.lazycreate,
};
__exportStar(require('./ZodError.ts'), exports);
Loading

0 comments on commit 1a952b3

Please sign in to comment.