assertwill throw an error if the input
datais not a a string. So on any line after the assertion we're guaranteed to be dealing with a string input.
🤖 Note: Superstruct works well with TypeScript guards and assertions, so after calling
isyou can access your data in a type-safe way!
datais a valid
Userstruct will ensure that input data is an object with specific shape of properties, and with property values that match structs.
arrayfactory. For example:
optionalmeans that the value can also be
undefinedand it will still be considered valid.
optional, you can use
nullablefor properties that can also be
nullvalues. For example: