모델 :오브젝트의 중첩 특성을 변경
function model() {
return {
title: {
"content": undefined,
"validation": {
"type": "string",
"required": true,
"minLength": 1,
"maxLength": 3,
validationErrorMessage: "Your title must be a valid string between 1 and 35 characters"
}
},
email: {
content: undefined,
validation: {
type: "email",
required: true,
minLength: 1,
maxLength: 60,
validationErrorMessage: "Your email must be between 1 and 50 characters"
}
},
link: {
content: undefined,
validation: {
type: "url",
required: true,
minLength: 1,
maxLength: 500,
validationErrorMessage: "Your link name must be a valid email between 1 and 50 characters"
}
},
description: {
content: undefined
}
}
}
Ramda 번호 :
let test = R.map(x => console.log(x.validation), model)
console.log(test)
로그 결과 올 : 다음
{ type: 'string',
required: true,
minLength: 1,
maxLength: 3,
validationErrorMessage: 'Your title must be a valid string between 1 and 35 characters' }
{ type: 'email',
required: true,
minLength: 1,
maxLength: 60,
validationErrorMessage: 'Your email must be between 1 and 50 characters' }
{ type: 'url',
required: true,
minLength: 1,
maxLength: 500,
validationErrorMessage: 'Your link name must be a valid email between 1 and 50 characters' }
undefined
{ title: undefined,
email: undefined,
link: undefined,
description: undefined }
않는 이유 :
let test = R.map(x => x.validation = "replacement test", model)
console.log(test)
로그 :
내가 기대 x.validation의 콘텐츠를 교체해야 할 것{ title: 'replacement test',
email: 'replacement test',
link: 'replacement test',
description: 'replacement test' }
, 전체가 아닌 x 값. 나는 그것을 얻지 못한다.
제목 개체가 다른 모든 개체와 다른 이유는 무엇입니까? –
'linkmodel'을'model'으로 참조합니까? – Andru
예, 죄송합니다. 수정되었습니다. –