Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.

Commit 3fe8e9c

Browse files
committed
v1.0.7
1 parent 150a75d commit 3fe8e9c

31 files changed

Lines changed: 57 additions & 57 deletions

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,7 @@ Validate the properties with your Teyit schema.
224224
> let fields;
225225
>
226226
> try {
227-
> fields = teyit.validate(schema, properties);
227+
> fields = await teyit.validate(schema, properties);
228228
> /*
229229
> {
230230
> display_name: "Fırat",
@@ -274,7 +274,7 @@ Declare your Teyit schema for TypeScript.
274274
> let fields;
275275
>
276276
> try {
277-
> fields = teyit.validate(schema, properties) as User;
277+
> fields = (await teyit.validate(schema, properties)) as User;
278278
> /*
279279
> interface User {
280280
> display_name: string;

src/Teyit.class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ export class Teyit {
4747
}
4848
}
4949

50-
public validate<const _Schema extends Schema>(schema: _Schema, properties: AnyObject): InferSchema<_Schema> {
50+
public validate<const _Schema extends Schema>(schema: _Schema, properties: AnyObject): Promise<InferSchema<_Schema>> {
5151
return validate(schema, properties, this.options);
5252
}
5353

src/utils/Engine.util.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ const seedMissingProperties = (schema: unknown, properties: unknown) => {
8585
}
8686
};
8787

88-
export const validate = <const _Schema extends Schema>(schema: _Schema, properties: UnknownObject, options: TeyitOptions): InferSchema<_Schema> => {
88+
export const validate = async <const _Schema extends Schema>(schema: _Schema, properties: UnknownObject, options: TeyitOptions): Promise<InferSchema<_Schema>> => {
8989
if (Array.isArray(schema)) {
9090
const schema_union = schema as Record<string, Type>[];
9191

@@ -95,7 +95,7 @@ export const validate = <const _Schema extends Schema>(schema: _Schema, properti
9595
try {
9696
const properties_clone = structuredClone(properties);
9797

98-
const valid_properties = validate(schema_single, properties_clone, options);
98+
const valid_properties = await validate(schema_single, properties_clone, options);
9999

100100
return valid_properties as InferSchema<_Schema>;
101101
} catch (error) {

tests/Array/Max.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const faulty_properties = [
3030

3131
for (let i = 0; i < correct_properties.length; i++) {
3232
try {
33-
teyit.validate(schema, correct_properties[i]);
33+
await teyit.validate(schema, correct_properties[i]);
3434

3535
console.log(`✅ Success ${String(i + 1)}/${String(correct_properties.length)} [CORRECT_PROPERTIES]`);
3636
} catch {
@@ -40,7 +40,7 @@ for (let i = 0; i < correct_properties.length; i++) {
4040

4141
for (let i = 0; i < faulty_properties.length; i++) {
4242
try {
43-
teyit.validate(schema, faulty_properties[i]);
43+
await teyit.validate(schema, faulty_properties[i]);
4444

4545
throw new Error(`❌ Error ${String(i + 1)}/${String(faulty_properties.length)} [FAULTY_PROPERTIES]`);
4646
} catch (error) {

tests/Array/Min.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ const faulty_properties = [
3030

3131
for (let i = 0; i < correct_properties.length; i++) {
3232
try {
33-
teyit.validate(schema, correct_properties[i]);
33+
await teyit.validate(schema, correct_properties[i]);
3434

3535
console.log(`✅ Success ${String(i + 1)}/${String(correct_properties.length)} [CORRECT_PROPERTIES]`);
3636
} catch {
@@ -40,7 +40,7 @@ for (let i = 0; i < correct_properties.length; i++) {
4040

4141
for (let i = 0; i < faulty_properties.length; i++) {
4242
try {
43-
teyit.validate(schema, faulty_properties[i]);
43+
await teyit.validate(schema, faulty_properties[i]);
4444

4545
throw new Error(`❌ Error ${String(i + 1)}/${String(faulty_properties.length)} [FAULTY_PROPERTIES]`);
4646
} catch (error) {

tests/Array/Type.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const faulty_properties = [
2929

3030
for (let i = 0; i < correct_properties.length; i++) {
3131
try {
32-
teyit.validate(schema, correct_properties[i]);
32+
await teyit.validate(schema, correct_properties[i]);
3333

3434
console.log(`✅ Success ${String(i + 1)}/${String(correct_properties.length)} [CORRECT_PROPERTIES]`);
3535
} catch {
@@ -39,7 +39,7 @@ for (let i = 0; i < correct_properties.length; i++) {
3939

4040
for (let i = 0; i < faulty_properties.length; i++) {
4141
try {
42-
teyit.validate(schema, faulty_properties[i]);
42+
await teyit.validate(schema, faulty_properties[i]);
4343

4444
throw new Error(`❌ Error ${String(i + 1)}/${String(faulty_properties.length)} [FAULTY_PROPERTIES]`);
4545
} catch (error) {

tests/Base/Nullable.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const properties = {
3636

3737
for (let i = 0; i < correct_schemas.length; i++) {
3838
try {
39-
teyit.validate(correct_schemas[i], properties);
39+
await teyit.validate(correct_schemas[i], properties);
4040

4141
console.log(`✅ Success ${String(i + 1)}/${String(correct_schemas.length)} [CORRECT_SCHEMAS]`);
4242
} catch {
@@ -46,7 +46,7 @@ for (let i = 0; i < correct_schemas.length; i++) {
4646

4747
for (let i = 0; i < faulty_schemas.length; i++) {
4848
try {
49-
teyit.validate(faulty_schemas[i], properties);
49+
await teyit.validate(faulty_schemas[i], properties);
5050

5151
throw new Error(`❌ Error ${String(i + 1)}/${String(faulty_schemas.length)} [FAULTY_SCHEMAS]`);
5252
} catch (error) {

tests/Base/Pattern.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const faulty_properties = [
2525

2626
for (let i = 0; i < correct_properties.length; i++) {
2727
try {
28-
teyit.validate(schema, correct_properties[i]);
28+
await teyit.validate(schema, correct_properties[i]);
2929

3030
console.log(`✅ Success ${String(i + 1)}/${String(correct_properties.length)} [CORRECT_PROPERTIES]`);
3131
} catch {
@@ -35,7 +35,7 @@ for (let i = 0; i < correct_properties.length; i++) {
3535

3636
for (let i = 0; i < faulty_properties.length; i++) {
3737
try {
38-
teyit.validate(schema, faulty_properties[i]);
38+
await teyit.validate(schema, faulty_properties[i]);
3939

4040
throw new Error(`❌ Error ${String(i + 1)}/${String(faulty_properties.length)} [FAULTY_PROPERTIES]`);
4141
} catch (error) {

tests/Base/Required.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const faulty_properties = [{}];
2020

2121
for (let i = 0; i < correct_properties.length; i++) {
2222
try {
23-
teyit.validate(schema, correct_properties[i]);
23+
await teyit.validate(schema, correct_properties[i]);
2424

2525
console.log(`✅ Success ${String(i + 1)}/${String(correct_properties.length)} [CORRECT_PROPERTIES]`);
2626
} catch {
@@ -30,7 +30,7 @@ for (let i = 0; i < correct_properties.length; i++) {
3030

3131
for (let i = 0; i < faulty_properties.length; i++) {
3232
try {
33-
teyit.validate(schema, faulty_properties[i]);
33+
await teyit.validate(schema, faulty_properties[i]);
3434

3535
throw new Error(`❌ Error ${String(i + 1)}/${String(faulty_properties.length)} [FAULTY_PROPERTIES]`);
3636
} catch (error) {

tests/Boolean/Type.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const faulty_properties = [
2424

2525
for (let i = 0; i < correct_properties.length; i++) {
2626
try {
27-
teyit.validate(schema, correct_properties[i]);
27+
await teyit.validate(schema, correct_properties[i]);
2828

2929
console.log(`✅ Success ${String(i + 1)}/${String(correct_properties.length)} [CORRECT_PROPERTIES]`);
3030
} catch {
@@ -34,7 +34,7 @@ for (let i = 0; i < correct_properties.length; i++) {
3434

3535
for (let i = 0; i < faulty_properties.length; i++) {
3636
try {
37-
teyit.validate(schema, faulty_properties[i]);
37+
await teyit.validate(schema, faulty_properties[i]);
3838

3939
throw new Error(`❌ Error ${String(i + 1)}/${String(faulty_properties.length)} [FAULTY_PROPERTIES]`);
4040
} catch (error) {

0 commit comments

Comments
 (0)