Skip to content

Commit

Permalink
Merge branch 'release/v0.24.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed Aug 26, 2024
2 parents ca3333f + 558279d commit c6f2715
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeed",
"type": "module",
"version": "0.24.5",
"version": "0.24.6",
"description": "🌱 Simple foundation library",
"author": {
"name": "Dirk Holtwick",
Expand Down
7 changes: 3 additions & 4 deletions src/common/schema/schema.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand All @@ -14,7 +14,7 @@ describe('schema', () => {
// status: stringLiterals(['active', 'trialing', 'past_due', 'paused', 'deleted']),
status: string<Status>(),
obj: object({
test: number(),
test: float(),
}).optional(),
})

Expand All @@ -36,9 +36,8 @@ describe('schema', () => {
"type": "boolean",
},
"age": Object {
"_integer": true,
"_optional": true,
"type": "number",
"type": "int",
},
"id": Object {
"type": "string",
Expand Down
5 changes: 3 additions & 2 deletions src/common/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,10 @@ export function number<T = number>() {
})
}

export const float = number

export function int<T = number>() {
return generic<T>('number', {
_integer: true,
return generic<T>('int', {
_check: isInteger,
})
}
Expand Down
3 changes: 1 addition & 2 deletions src/common/schema/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<T = unknown> {
type: TypeNames
Expand All @@ -12,7 +12,6 @@ export interface Type<T = unknown> {
_default?: T | (() => T)
_object?: SchemaDefinitionObject<Type<T>>
_union?: Type[]
_integer?: boolean

_check: (obj: any) => boolean

Expand Down

0 comments on commit c6f2715

Please sign in to comment.