@@ -738,6 +738,69 @@ orm.connect("....", function (err, db) {
738738});
739739```
740740
741+ ### Predefined Validations
742+
743+ Predefined validations accept an optional last parameter ` msg ` that is the ` Error.msg ` if it's triggered.
744+
745+ #### ` required(msg) `
746+
747+ Ensures property is not ` null ` or ` undefined ` . It does not trigger any error if property is ` 0 ` or empty string.
748+
749+ #### ` rangeNumber(min, max, msg) `
750+
751+ Ensures a property is a number between ` min ` and ` max ` . Any of the parameters can be passed as ` undefined `
752+ to exclude a minimum or maximum value.
753+
754+ #### ` rangeLength(min, max, msg) `
755+
756+ Same as previous validator but for property length (strings).
757+
758+ #### ` insideList(list, msg) `
759+
760+ Ensures a property value is inside a list of values.
761+
762+ #### ` outsideList(list, msg) `
763+
764+ Ensures a property value is not inside a list of values.
765+
766+ #### ` equalToProperty(property, msg) `
767+
768+ Ensures a property value is not the same as another property value in the instance. This validator is good for example for
769+ password and password repetition check.
770+
771+ #### ` notEmptyString(msg) `
772+
773+ This is an alias for ` rangeLength(1, undefined, 'empty-string') ` .
774+
775+ #### ` unique(msg) `
776+
777+ Ensures there's not another instance in your database already with that property value. This validator is good for example for
778+ unique identifiers.
779+
780+ #### ` password([ checks, ]msg) `
781+
782+ Ensures the property value has some defined types of characters, usually wanted in a password. ` checks ` is optional and
783+ defaults to ` "luns6" ` which leans ` l ` owercase letters, ` u ` ppercase letters, ` n ` umbers, ` s ` pecial characters, with a minimum
784+ length of ` 6 ` .
785+
786+ #### ` patterns.match(pattern, modifiers, msg) `
787+
788+ Ensures the property value passes the regular expression pattern (and regex modifiers).
789+
790+ The next ` patterns.* ` are comodity alias to this one.
791+
792+ #### ` patterns.hexString(msg) `
793+
794+ Ensures the property value is an hexadecimal string (uppercase or lowercase).
795+
796+ #### ` patterns.email(msg) `
797+
798+ Ensures the property value is a valid e-mail (more or less).
799+
800+ #### ` patterns.ipv4(msg) `
801+
802+ Ensures the property value is a valid IPv4 address. It does not accept masks (example: ` 0 ` as last number is not valid).
803+
741804## Associations
742805
743806An association is a relation between one or more tables.
0 commit comments