Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions customSchemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,15 @@ export function Uint8ArrayType(

return true;
},
(value) => {
if (!(value instanceof Uint8Array)) return 'expected Uint8Array';
if (min !== undefined && value.byteLength < min)
return `Uint8Array byteLength must be >= ${min}`;
if (max !== undefined && value.byteLength > max)
return `Uint8Array byteLength must be <= ${max}`;

return 'invalid Uint8Array';
},
);

uint8ArrayCache.set(key, schema);
Expand Down Expand Up @@ -86,6 +95,16 @@ export function DateType(

return true;
},
(value) => {
if (!(value instanceof Date)) return 'expected Date';
if (isNaN(value.getTime())) return 'expected valid Date';
if (typeof min === 'number' && value.getTime() < min)
return `Date timestamp must be >= ${min}`;
if (typeof max === 'number' && value.getTime() > max)
return `Date timestamp must be <= ${max}`;

return 'invalid Date';
},
);

dateCache.set(key, schema);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@replit/river",
"description": "It's like tRPC but... with JSON Schema Support, duplex streaming and support for service multiplexing. Transport agnostic!",
"version": "0.217.0",
"version": "0.217.1",
"type": "module",
"exports": {
".": "./dist/router/index.js",
Expand Down
4 changes: 3 additions & 1 deletion router/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,9 @@ export function validationErrorToRiverErrors(

if (propertyNames) {
return propertyNames.map((prop) => ({
path: `${error.instancePath}/${prop}`,
path: `${error.instancePath}/${prop
.replace(/~/g, '~0')
.replace(/\//g, '~1')}`,
message: error.message,
}));
}
Expand Down
Loading