Sanitizer
Data & parameter sanitizer
Every document that goes to the database needs to be sanitized first. This is to ensure that the document is properly saved according its schema definition.
If schema collection is provided (i.e: attributes
isn't empty), then on every create()
and update()
operation the body parameter is automatically sanitized:
According to its type:
boolean
,date
,datetime
,float
, andinteger
will automatically sanitized using its related sanitizer.According to its sanitizer definition below.
You can put one or more sanitizer on every attributes. Sanitizers put manually on attributes will override the one automatically provided according to its type.
Example:
From the example above:
username
will be trimmed from whitespace and accept any character except 1, 2, 3, 4 and 5name
will be trimed from whitespacegender
will be converted usingtoBoolean
sanitizerbirth_date
will be parsed usingYYYY-MM-DD
patternemail
will be sanitized usingnormalizeEmail
with custom options
If error occurs, or value doesn't match the provided pattern, value will be converted to null
All validator.js sanitizers are supported:
Last updated