My approach to this is to use something like Joi or Yup to validate the input. Our teams also follow a convention that if you have more than 3 arguments to make it an object.
The other reason to use something like Joi or Yup is you can have more finite control of what's passed in, so instead of having validation statements to check if a persons page is between 0-120 for example you can define that in a schema.
Thirdly if you use TypeScript this the required check is a non-issue. The compiler will validate that for you.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Nice article, some thoughts form the sidelines.
My approach to this is to use something like Joi or Yup to validate the input. Our teams also follow a convention that if you have more than 3 arguments to make it an object.
The other reason to use something like Joi or Yup is you can have more finite control of what's passed in, so instead of having validation statements to check if a persons page is between 0-120 for example you can define that in a schema.
Thirdly if you use TypeScript this the required check is a non-issue. The compiler will validate that for you.