deno.land / x / mongoose@6.7.5 / docs / tutorials / custom-casting.md
Mongoose 5.4.0 introduced several ways to configure SchemaTypes globally. One of these new features is the SchemaType.cast()
function, which enables you to override Mongoose's built-in casting.
For example, by default Mongoose will throw an error if you attempt to cast a string that contains a Japanese numeral to a number.
[require:custom casting.*casting error]
You can overwrite the default casting function for numbers to allow converting the string that contains the Japanese numeral "2" to a number as shown below.
[require:custom casting.*casting override]
Version Info