Skip to content

Commit

Permalink
fix(validator): change ValidType to StringifyableRecord
Browse files Browse the repository at this point in the history
  • Loading branch information
AliMD authored and njfamirm committed Feb 25, 2023
1 parent 4c5f669 commit ca1e191
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
4 changes: 0 additions & 4 deletions core/validator/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,3 @@ export type JsonSchema = {
| boolean
| null;
};

export type ValidType = {
[key: string]: ValidType | string | number | boolean | null;
};
6 changes: 3 additions & 3 deletions core/validator/src/validator.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import {isNumber} from '@alwatr/math';

import type {JsonSchema, ValidType} from './type.js';
import type {JsonSchema} from './type.js';
import type {Stringifyable, StringifyableRecord} from '@alwatr/type';

export type {JsonSchema};

export function validator<T extends ValidType>(
export function validator<T extends StringifyableRecord>(
validSchema: JsonSchema,
targetObject: StringifyableRecord,
additionalProperties = false,
Expand Down Expand Up @@ -45,7 +45,7 @@ export function validator<T extends ValidType>(

if (typeof itemSchema === 'object' && itemSchema != null) {
// nested object
targetObject[itemName] = validator<ValidType>(
targetObject[itemName] = validator<StringifyableRecord>(
itemSchema,
itemValue as StringifyableRecord,
additionalProperties,
Expand Down

0 comments on commit ca1e191

Please sign in to comment.