Allow optional fields in table
Nobody has claimed this yet.
- Dominant language
- Lua
- Stars
- 20
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
Introduce special property for table: __checks__skip__omitted__. If it's set to true, 'table' check will allow not fail check on table if it has more properties than we pass to checks.
Reason:
There's lot of legacy code that needs proper parameters checks, but 'table' is too strict because it doesn't allow additional fields. Correcting everything is very time consuming and, sometimes, doesn't make sense. Proposed check will allow gradual changes in code from "no checks at all" to "everything is checked".
Sample usage:
local function f(arg1)
checks({ a = 'string', b = 'number', __checks__skip__omitted = true})
end
f({ 'a' = 'abc', b = 2 }) -- ok
f({ 'a' = 'abc', b = 2, c = '3' }) -- also ok
f({ 'a' = 123, b = 2, c = '3' }) -- not ok
f({ 'a' = 'abc', b = '2', c = '3' }) -- not ok
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the implementation of the table check and the existing tests for table properties. Add coverage for __checks__skip__omitted = true, verifying that extra fields are accepted while incorrect types for declared fields still fail, then run the relevant test suite.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- tooling
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100