07. December 2021
Email sanitizers, nullable validation, dynamic content negotiation
Validator features
@adonisjs/[email protected] added some additional email sanitization and nullable validation rules
removeDots
- removes all dots from emails. Turns [email protected]
to [email protected]
removeSubaddress
- removes sub-addresses that can be added with +
. Turns [email protected]
to [email protected]
And also additional validator rules:
nullable
- allows field to be null
, but it must exist
nullableAndOptional
- allows field to be both null
or not exist at all
You can read from docs about new rules
Dynamic content negotiation
From @adonisjs/[email protected] app.forceContentNegotiationTo
config option can be function
It’s useful when having both API and SSR application at the same time
For example you might have admin panel, that doesn’t need content to be forced to JSON, while API needs it
In that case you can make routes starting with /api
be forced to JSON while rest stays as-is