Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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]);
}
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]);
}
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]);
ARRAY_UNIQUE: "Array items are not unique (indices {match1} and {match2})",
ARRAY_ADDITIONAL_ITEMS: "Additional items not allowed",
// Format errors
FORMAT_CUSTOM: "{message}",
KEYWORD_CUSTOM: "{message}",
// Schema structure
CIRCULAR_REFERENCE: "Circular $refs: {urls}",
// Non-standard validation options
UNKNOWN_PROPERTY: "Unknown property (not in schema)"
});
// Set the new language we just defined
tv4.language("en-us");
const SchemaFormUtil = {
/**
* Finds a specific field definition when a path is passed in.
*
* @param {Object} definition Definition to traverse to find the field definition.
* @param {Array} paths Array of the properties needed to lookup to get to
* definition.
*
* @return {Object} definition The definition that was found, or the
* definition before the dead end.
*/
getDefinitionFromPath(definition, paths) {
if (definition[paths[0]]) {
definition = definition[paths[0]];
paths = paths.slice(1);
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);
}
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), userCustomFormat);
tv4.addFormat(allFormats);
}, [t]);
resolve.setLanguage = function(lang) {
currentLang = lang;
tv4.language(lang);
};
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);
}
};
/**
* Set language
*/
resolve.setLanguage = function(lang) {
currentLang = lang;
tv4.language(lang);
};
['en','ja'].forEach(lang => {
let res = require('./'+lang);
resolve.merge(res, lang);
if (res.tv4) {
tv4.addLanguage(lang, res.tv4);
}
});
tv4.language(currentLang);
export default resolve;