Can I use the same intl class outside React? #4850
-
I'm using the Ant.design as UI kit and Antd's forms has a export const validateNonEmptyArray = async (_: RuleObject, value: string[]) => {
if (!Array.isArray(value) || value.length === 0) {
return Promise.reject(new Error('Please select at least one option.'));
}
const [datetime] = value
const minutes = moment.duration(moment(datetime).diff(moment())).asMinutes()
if (minutes <= CAMPAIGN_START_MINIMUM_GAP) {
return Promise.reject(new Error('The campaign must be scheduled at least 15 minutes before its start.'));
}
return Promise.resolve();
}; I have to made a localization for rejection messages. How could I use the class export const getIntlValidator = (intl) => async (_: RuleObject, value: string[]) => {}… but I don't like this solution. Is there any other option? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
yup you can use https://formatjs.github.io/docs/intl#createintl |
Beta Was this translation helpful? Give feedback.
yup you can use https://formatjs.github.io/docs/intl#createintl