Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
state.widgets = { ...state.widgets, ...props.widgets };
this.state = state;
this.onChange = this.onChange.bind(this);
this.onFinish = this.onFinish.bind(this);
this.onSubmit = this.onSubmit.bind(this);
this.onTrigger = this.onTrigger.bind(this);
this.onActionClick = this.onActionClick.bind(this);
this.focusFirstError = this.focusFirstError.bind(this);
this.setFormRef = this.setFormRef.bind(this);
// control the tv4 language here.
const language = getLanguage(props.t);
if (props.language != null) {
Object.assign(language, props.language);
// Force update of language @talend even if already set
tv4.addLanguage('@talend', language);
tv4.language('@talend');
}
if (!tv4.language('@talend')) {
tv4.addLanguage('@talend', language);
tv4.language('@talend'); // set it
}
const allFormats = Object.assign(customFormats(props.t), props.customFormats);
tv4.addFormat(allFormats);
}
useEffect(() => {
// control the tv4 language here.
const mergedLanguage = getLanguage(t);
if (language != null) {
Object.assign(mergedLanguage, language);
// Force update of language @talend even if already set
tv4.addLanguage('@talend', mergedLanguage);
tv4.language('@talend');
}
if (!tv4.language('@talend')) {
tv4.addLanguage('@talend', mergedLanguage);
tv4.language('@talend'); // set it
}
const allFormats = Object.assign(customFormats(t), userCustomFormats);
tv4.addFormat(allFormats);
}, [t]);
}
//
// - null : No error
// - 'string' : The error description
//
validationFunction(data)
);
/**
* The default tv4 error messages are quite bad.
* Here are a bit more user-friendly alternatives
*
* The default language is 'en-gb', so by setting
* the language to 'en-us' we are introducing our
* prettier version of error messages :)
*/
tv4.addLanguage("en-us", {
// Generic errors
INVALID_TYPE: "Expecting a {expected} here",
ENUM_MISMATCH: "No enum match for: {value}",
ANY_OF_MISSING: "Data does not match any schemas from 'anyOf'",
ONE_OF_MISSING: "Data does not match any schemas from 'oneOf'",
ONE_OF_MULTIPLE:
"Data is valid against more than one schema from 'oneOf': indices {index1} and {index2}",
NOT_PASSED: "Data matches schema from 'not'",
// Numeric errors
NUMBER_MULTIPLE_OF: "Must be a multiple of {multipleOf}",
NUMBER_MINIMUM: "Must be bigger than or equal to {minimum}",
NUMBER_MINIMUM_EXCLUSIVE: "Must be bigger than {minimum}",
NUMBER_MAXIMUM: "Must be smaller than or equal to {maximum}",
NUMBER_MAXIMUM_EXCLUSIVE: "Must be smaller than {maximum}",
NUMBER_NOT_A_NUMBER: "'{value}' is not a valid number",
useEffect(() => {
// control the tv4 language here.
const mergedLanguage = getLanguage(t);
if (language != null) {
Object.assign(mergedLanguage, language);
// Force update of language @talend even if already set
tv4.addLanguage('@talend', mergedLanguage);
tv4.language('@talend');
}
if (!tv4.language('@talend')) {
tv4.addLanguage('@talend', mergedLanguage);
tv4.language('@talend'); // set it
}
const allFormats = Object.assign(customFormats(t), userCustomFormat);
tv4.addFormat(allFormats);
}, [t]);
['en','ja'].forEach(lang => {
let res = require('./'+lang);
resolve.merge(res, lang);
if (res.tv4) {
tv4.addLanguage(lang, res.tv4);
}
});
tv4.language(currentLang);
validate: function(schema, data) {
var translation = config.jsonSchemaValidatorTranslation.draft4 || {};
if (!_.isEmpty(translation)) {
tv4.addLanguage(translation.language, translation.mapping);
tv4.language(translation.language);
}
var result = tv4.validateMultiple(data, schema);
return formatError(schema, result);
}
};