I want to present you this problem I have searched all over google but I can't find a solution, I want to create a custom validation to yup, I follow the guides and in react when I save the validation it works fine, but when I press f5 I get this error.
These are the files that I use to create the validation
Fragment:CrearGenero
const schema = yup.object({
nombre: yup.string().required().primeraLetraMayuscula()
})
File:Global.d.ts
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import { StringSchema } from "yup";
declare module 'yup'{
interface StringSchema {
primeraLetraMayuscula(): this
}
}
File:Validations.ts
import * as yup from 'yup'
export default function configurarValidaciones() {
yup.addMethod(yup.string, 'primeraLetraMayuscula', function () {
return this.test('primeramayuscula', 'La primera letra debe ser mayuscula',
function (valor) {
if (valor && valor.length > 0) {
const primeraLetra = valor.substring(0, 1);
return primeraLetra === primeraLetra.toUpperCase();
}
return true;
}
)
})
}
Thanks