Skip to content

Commit e61bdb4

Browse files
authored
Merge pull request #1358 from minenwerfer/minenwerfer/update-aeria
feat: update aeria
2 parents d591f28 + 65c1dc3 commit e61bdb4

File tree

4 files changed

+280
-73
lines changed

4 files changed

+280
-73
lines changed

bun.lockb

-59.9 KB
Binary file not shown.

cases/aeria/index.ts

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { silentValidator } from '@aeriajs/validation';
1+
import { validate } from '@aeriajs/validation';
22
import { createCase } from '../../benchmarks';
33

44
const schema = {
@@ -50,58 +50,38 @@ const schema = {
5050
} as const;
5151

5252
createCase('aeria', 'parseSafe', () => {
53-
const [_, validate] = silentValidator(schema, {
54-
extraneous: true,
55-
filterOutExtraneous: true,
56-
coerce: true,
57-
});
58-
59-
return (data: any) => {
60-
const result = validate(data);
61-
if (!result) {
62-
throw new Error();
63-
}
64-
65-
return result;
53+
return (data: unknown) => {
54+
return validate(data, schema, {
55+
throwOnError: true,
56+
tolerateExtraneous: true,
57+
}).result;
6658
};
6759
});
6860

6961
createCase('aeria', 'parseStrict', () => {
70-
const [_, validate] = silentValidator(schema, {
71-
coerce: true,
72-
});
73-
74-
return (data: any) => {
75-
const result = validate(data);
76-
if (!result) {
77-
throw new Error();
78-
}
79-
80-
return result;
62+
return (data: unknown) => {
63+
return validate(data, schema, {
64+
throwOnError: true,
65+
}).result;
8166
};
8267
});
8368

8469
createCase('aeria', 'assertLoose', () => {
85-
const [_, validate] = silentValidator(schema, {
86-
extraneous: true,
87-
});
88-
89-
return (data: any) => {
90-
if (!validate(data)) {
91-
throw new Error();
92-
}
70+
return (data: unknown) => {
71+
validate(data, schema, {
72+
throwOnError: true,
73+
tolerateExtraneous: true,
74+
});
9375

9476
return true;
9577
};
9678
});
9779

9880
createCase('aeria', 'assertStrict', () => {
99-
const [_, validate] = silentValidator(schema);
100-
101-
return (data: any) => {
102-
if (!validate(data)) {
103-
throw new Error();
104-
}
81+
return (data: unknown) => {
82+
validate(data, schema, {
83+
throwOnError: true,
84+
});
10585

10686
return true;
10787
};

0 commit comments

Comments
 (0)