js-lib icon indicating copy to clipboard operation
js-lib copied to clipboard

feat: make `j` rules immutable

Open mrnagydavid opened this issue 3 months ago • 0 comments

In this PR, I showcase one pattern to make j immutable: with decorators on every method that mutates this.schema.

Why immutability? To avoid such issues:

export const mySchema = j.object({ ... })

// someone else
import { mySchema }
const schema = mySchema.optional() // <-- this makes `mySchema` optional **everywhere**

mrnagydavid avatar Nov 21 '25 16:11 mrnagydavid