Skip to content

Conversation

@niskyB
Copy link

@niskyB niskyB commented Dec 24, 2025

Description

IsObject returned true for functions despite the documented behavior. This PR resolves the issue by introducing an option to exclude functions from object checks.

Checklist

  • the pull request title describes what this PR does (not a vague title like Update index.md)
  • the pull request targets the default branch of the repository (develop)
  • the code follows the established code style of the repository
    • npm run prettier:check passes
    • npm run lint:check passes
  • tests are added for the changes I made (if any source code was modified)
  • documentation added or updated
  • I have run the project locally and verified that there are no errors

Fixes

fixes #2515

@Setitch
Copy link

Setitch commented Dec 30, 2025

let a = () => {};
console.log(typeof a); // outcome => "function"
console.log(a instanceof Object); // outcome => true

Functions are objects in js therefore isObject should treat functions as objects by JS standard.
However i presume additional option passed to decorator which would allow some control (exclude functions from being treated by the validator as objects) would be much better than going against the language principles.

@niskyB
Copy link
Author

niskyB commented Dec 31, 2025

Could you please check this again? @Setitch

@niskyB niskyB changed the title fix: IsObject should return false for function feat: add an option to IsObject to exclude functions from object checks. Jan 1, 2026
@niskyB niskyB changed the title feat: add an option to IsObject to exclude functions from object checks. feat: add an option to IsObject to exclude functions from object checks Jan 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

fix: isObject returns true for functions but docs say it should be false

2 participants