I have a function in my react-native package that requires "from" and "to" dates as parameters.
I need to implement a rule that ensures the "to" date is always after the "from" date.
Where should I insert this requirement in the following code snippet?
const fetchData: fetchDataMethod = async ( //function definition
identifier,
options
) => {
const processedOptions = processInput(options)
return processedOptions
}
const processInput = (options: InputParameters) => { //processing input function
const limit = options.limit ?? 0
const ascending = options.ascending ?? true
const from = convertDateToString(options.from)
const to = convertDateToString(options.to)
return { limit, ascending, from, to }
}
const convertDateToString = (date?: Date | null): string => { //convert date to string function
return date ? date.toISOString() : new Date(0).toISOString()
}
export type InputParameters = { //type declaration
from?: Date
to?: Date
limit?: Number
ascending?: boolean
};