Open mandrillxx opened 1 month ago
Thanks for the suggestion - that'd be a nice addition, can't promise but will try to make it into https://github.com/colyseus/schema/pull/173
For now, I'd suggest inserting empty Player
instances instead of having the null
values.
Description & Use case
Description: Add the ability to add null/undefined objects within ArraySchema type
currently, this is restricted by this check in src/types/ArraySchema.ts#182
Usecase: My backend for a poker game is already made, and an array is made for the player seating:
and somebody can join any seat index, meaning the array can look like this:
but when converting to a schema
this will no longer work, and the array will be empty. as seen in the failing test
alongside null/undefined being integral parts of typescript/javascript, so maybe exclusively for js ecosystem
Optional: Proposed API
maybe a separate schema type, such as NullableArraySchema