Every witness before testifying shall take an oath or make an affirmation or declaration in the form provided by law, except that a child under the age of 10 or a dependent person with a substantial cognitive impairment, in the court’s discretion, may be required only to promise to tell the truth.