Last active
December 26, 2015 20:14
-
-
Save danielb2/64d8974e44d39882e891 to your computer and use it in GitHub Desktop.
Revisions
-
danielb2 revised this gist
Dec 26, 2015 . 1 changed file with 4 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,18 +1,19 @@ ### `alternatives` Generates a type that will match one of the provided alternative schemas via the [`try()`](#alternativestryschemas) method. If no schemas are added, the type will not match any value except for `undefined`. Schemas can be expressed as multiple arguments or given as an array. Supports the same methods of the [`any()`](#any) type. ```javascript var alt = Joi.alternatives().try(Joi.number(), Joi.string()); // Same as var alt = Joi.alternatives.try([Joi.number(), Joi.string()]) ``` Alternatives can be expressed using a shorter notation. ```javascript var alt = Joi.alternatives(Joi.number(), Joi.string()) // Same as var alt = Joi.alternatives.try([Joi.number(), Joi.string()]) ``` -
danielb2 revised this gist
Dec 26, 2015 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -14,6 +14,5 @@ Alternatives can be expressed using a shorter notation. ```javascript var alt = Joi.alternatives(Joi.number(), Joi.string()) // or: var alt = Joi.alternatives.try([Joi.number(), Joi.string()]) ``` -
danielb2 revised this gist
Dec 26, 2015 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -10,10 +10,10 @@ var alt = Joi.alternatives().try(Joi.number(), Joi.string()); // or: var alt = Joi.alternatives.try([Joi.number(), Joi.string()]) ``` Alternatives can be expressed using a shorter notation. ```javascript var alt = Joi.alternatives(Joi.number(), Joi.string()) // or: var alt = Joi.alternatives.try([Joi.number(), Joi.string()]) ``` -
danielb2 created this gist
Dec 26, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ ### `alternatives` Generates a type that will match one of the provided alternative schemas via the [`try()`](#alternativestryschemas) method. If no schemas are added, the type will not match any value except for `undefined`. Supports the same methods of the [`any()`](#any) type. ```javascript var alt = Joi.alternatives().try(Joi.number(), Joi.string()); // or: var alt = Joi.alternatives.try([Joi.number(), Joi.string()]) ``` Alternatives can be expressed using the shorter `[]` notation. ```javascript var alt = Joi.alternatives.try([Joi.number(), Joi.string()]) // or: var alt = Joi.alternatives(Joi.number(), Joi.string()) ```