Closed GoldraK closed 7 months ago
Hi @GoldraK . Thank you very much for the feedback. 🤗
But I couldn't understand the issue clearly? Do you get any errors? Or just isn't it working as expected?
@GoldraK I think I found the issue. You need to set which languages are supported first. After that yo can register your custom rules.
import { setLocales, register } from "robust-validator";
import en from "robust-validator/dist/i18n/en.json";
setLocales(en);
const isNullable = (value) => {
if (value === null || value === 'null') {
return true;
}
return false;
};
register(
'nullable',
isNullable,
{
en: "The {0} field must be null or empty."
}
)
Please let me know if that doesn't solve your problem.
Hello, First of all, thank you for the package, it works very well.
I'm trying to add a new rule for null cases but I can't get it to work.
I can't figure out why.
All the best.