Table of Contents
Always Pass Data in Validation Function
Example
Instead of:
function validate() {
const data = getGlobalData();
// validate the data
}
validate();
Always do this:
function validate(data: Record<string, string>) {
// validate the data
}
validate(data);
// or
validate(getGlobalData());
Why
It’s easier to debug the data or maintain the function.