I'm seeking to develop a unique validation function for express-validator in typescript by extending the 'body' object.
After reviewing the helpful resource page, I came across this code snippet:
import { ExpressValidator } from 'express-validator';
const { body } = new ExpressValidator(
{
isPostID: async value => {
// Confirm if the value aligns with the post ID format
},
},
);
When trying to implement this in VS Code, I encountered the error message "Parameter 'value' implicitly has 'any' type". One option would be to modify it to
isPostID: async value:any => ...
, but we are certain that the passed value will always be a string. I am unsure how to inform Typescript about this constraint. If you have any suggestions, please share them!