Skip to content

isGetter doesn't actually validate getters #59

@appsforartists

Description

@appsforartists

I'd expect isGetter to assert that a getter is valid (e.g. composed only of strings, optionally a trailing function, or other getters). Instead, it tests that an array ends in a function.

Valid getters that fail this test

["path"]

Invalid getters that pass

[1, true, null, () => ({})]

A more robust test

function isGetter(value) {
  return isArray(value) && value.every(
    (item, i) =>    isString(item)
                 || (i === value.length - 1 && isFunction(item))
                 || isGetter(item)
  );
}

It passes all the current getter tests.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions