Rest
...patterns: patternsmatch(value)
.with(
{
user: P.intersection(
{ firstname: P.string },
{ lastname: P.string },
{ age: P.when(age => age > 21) }
)
},
({ user }) => 'will match { firstname: string, lastname: string, age: number } if age > 21'
)
P.intersection(...patterns)
returns a pattern which matches only if every patterns provided in parameter match the input.Read the documentation for
P.intersection
on GitHub