I have a complete config object and another object that can be partially filled.
When merging them, I need the unchanged settings to remain.
let defaultConfig = {
locale: 'en',
messages: {
mixed: {
required: 'is required',
confirmed: 'is confirmed'
}
},
// outher configs...
}
let newConfig = {
locale: 'pt',
messages: {
mixed: {
required: 'é obrigatório'
}
}
}
defaultConfig = { ...defaultConfig, ...newConfig }
console.log(defaultConfig)
Result of the code above:
{
"locale": "pt",
"messages": {
"mixed": {
"required": "é obrigatório"
}
}
}
The expected result:
{
"locale:" "pt",
"messages": {
"mixed": {
"required": "é obrigatório",
"confirmed": "is confirmed"
}
}
}
Remember that there are other settings/properties, so anyway it needs to have merge logic.