From 6b43b196992460b5319eee648ee288a59835f9e5 Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Mon, 26 Aug 2024 14:39:59 +0200 Subject: [PATCH 1/2] fix: int details --- src/common/schema/schema.spec.ts | 7 +++---- src/common/schema/schema.ts | 5 +++-- src/common/schema/types.ts | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/common/schema/schema.spec.ts b/src/common/schema/schema.spec.ts index b06445c..d80e4b9 100644 --- a/src/common/schema/schema.spec.ts +++ b/src/common/schema/schema.spec.ts @@ -1,5 +1,5 @@ import { cloneJsonObject } from '../data' -import { boolean, int, literal, number, object, string, stringLiterals, union } from './schema' +import { boolean, float, int, literal, object, string, union } from './schema' import type { Infer } from './types' describe('schema', () => { @@ -14,7 +14,7 @@ describe('schema', () => { // status: stringLiterals(['active', 'trialing', 'past_due', 'paused', 'deleted']), status: string(), obj: object({ - test: number(), + test: float(), }).optional(), }) @@ -36,9 +36,8 @@ describe('schema', () => { "type": "boolean", }, "age": Object { - "_integer": true, "_optional": true, - "type": "number", + "type": "int", }, "id": Object { "type": "string", diff --git a/src/common/schema/schema.ts b/src/common/schema/schema.ts index 7793514..77d86d2 100644 --- a/src/common/schema/schema.ts +++ b/src/common/schema/schema.ts @@ -64,9 +64,10 @@ export function number() { }) } +export const float = number + export function int() { - return generic('number', { - _integer: true, + return generic('int', { _check: isInteger, }) } diff --git a/src/common/schema/types.ts b/src/common/schema/types.ts index 827fecd..5946c5d 100644 --- a/src/common/schema/types.ts +++ b/src/common/schema/types.ts @@ -3,7 +3,7 @@ export interface TypeProps { } -export type TypeNames = 'string' | 'number' | 'boolean' | 'object' | 'any' | string // | 'null' | 'undefined' | 'symbol' | 'bigint' +export type TypeNames = 'string' | 'number' | 'boolean' | 'int' | 'object' | 'any' | string // | 'null' | 'undefined' | 'symbol' | 'bigint' export interface Type { type: TypeNames @@ -12,7 +12,6 @@ export interface Type { _default?: T | (() => T) _object?: SchemaDefinitionObject> _union?: Type[] - _integer?: boolean _check: (obj: any) => boolean From 558279d88baddc475e6f4b2a7bd09ac77acad6f2 Mon Sep 17 00:00:00 2001 From: Dirk Holtwick Date: Mon, 26 Aug 2024 14:40:04 +0200 Subject: [PATCH 2/2] 0.24.6 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 8056822..f739c14 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "zeed", "type": "module", - "version": "0.24.5", + "version": "0.24.6", "description": "🌱 Simple foundation library", "author": { "name": "Dirk Holtwick",