Closed akphi closed 4 years ago
Does optional(custom())
make sense at all?
In any case, I think your example calls value => value.name
with value undefined
, which results in an error.
Maybe it makes more sense to write that if you're using custom, you don't need optional.
custom(v => v.?name ?? SKIP, v => {})
Does
optional(custom())
make sense at all?In any case, I think your example calls
value => value.name
with valueundefined
, which results in an error.Maybe it makes more sense to write that if you're using custom, you don't need optional.
custom(v => v.?name ?? SKIP, v => {})
@NaridaL yes! that's definitely my use case, and so I thought I could use optional
to be more declarative. For example:
const todoSchema = createSimpleSchema({
name: optional(custom(..)) // more declarative than 'custom( ... return SKIP ...)
})
Then I tried optional(custom())
and found out did not work quite the way I expected.
@pyrogenic thanks!
@NaridaL yes, I get that. I was not careful about giving the example in the doc but that's exactly the problem I faced when I used optional(custom())
. I thought optional
will happen first. I can correct the example to:
user: optional(custom(value => value?.name, () => SKIP))
@NaridaL I have corrected the example in #132
See discussion in #128