(name, getter)
| 202 | } |
| 203 | |
| 204 | getNestedField(name, getter) { |
| 205 | const fullNames = this.getValidFieldsFullName(name); |
| 206 | if ( |
| 207 | fullNames.length === 0 || // Not registered |
| 208 | (fullNames.length === 1 && fullNames[0] === name) // Name already is full name. |
| 209 | ) { |
| 210 | return getter(name); |
| 211 | } |
| 212 | const isArrayValue = fullNames[0][name.length] === '['; |
| 213 | const suffixNameStartIndex = isArrayValue ? name.length : name.length + 1; |
| 214 | return fullNames |
| 215 | .reduce( |
| 216 | (acc, fullName) => set( |
| 217 | acc, |
| 218 | fullName.slice(suffixNameStartIndex), |
| 219 | getter(fullName) |
| 220 | ), |
| 221 | isArrayValue ? [] : {} |
| 222 | ); |
| 223 | } |
| 224 | |
| 225 | getFieldsValue = (names) => { |
| 226 | return this.getNestedFields(names, this.getFieldValue); |
no test coverage detected