joi: add missing 'truncate' and 'normalize' to StringSchema

This commit is contained in:
Young Rok Kim
2017-11-01 10:54:02 +09:00
parent 165b07ef72
commit e764326427
4 changed files with 33 additions and 0 deletions
+12
View File
@@ -503,6 +503,18 @@ export interface StringSchema extends AnySchema {
max(limit: number, encoding?: string): this;
max(limit: Reference, encoding?: string): this;
/**
* Specifies whether the string.max() limit should be used as a truncation.
* @param enabled - optional parameter defaulting to true which allows you to reset the behavior of truncate by providing a falsy value.
*/
truncate(enabled?: boolean): this;
/**
* Requires the string value to be in a unicode normalized form. If the validation convert option is on (enabled by default), the string will be normalized.
* @param form - The unicode normalization form to use. Valid values: NFC [default], NFD, NFKC, NFKD
*/
normalize(form?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD'): this;
/**
* Requires the number to be a credit card number (Using Lunh Algorithm).
*/
+4
View File
@@ -773,6 +773,10 @@ strSchema = strSchema.isoDate();
strSchema = strSchema.lowercase();
strSchema = strSchema.uppercase();
strSchema = strSchema.trim();
strSchema = strSchema.truncate();
strSchema = strSchema.truncate(false);
strSchema = strSchema.normalize();
strSchema = strSchema.normalize('NFKC');
namespace common {
strSchema = strSchema.allow(x);
+13
View File
@@ -501,6 +501,19 @@ export interface StringSchema extends AnySchema {
max(limit: number, encoding?: string): this;
max(limit: Reference, encoding?: string): this;
/**
* Specifies whether the string.max() limit should be used as a truncation.
* @param enabled - optional parameter defaulting to true which allows you to reset the behavior of truncate by providing a falsy value.
*/
truncate(enabled?: boolean): this;
/**
* Requires the string value to be in a unicode normalized form. If the validation convert option is on (enabled by default), the string will be normalized.
* @param form - The unicode normalization form to use. Valid values: NFC [default], NFD, NFKC, NFKD
*/
normalize(form?: 'NFC' | 'NFD' | 'NFKC' | 'NFKD'): this;
/**
* Requires the number to be a credit card number (Using Lunh Algorithm).
*/
+4
View File
@@ -773,6 +773,10 @@ strSchema = strSchema.isoDate();
strSchema = strSchema.lowercase();
strSchema = strSchema.uppercase();
strSchema = strSchema.trim();
strSchema = strSchema.truncate();
strSchema = strSchema.truncate(false);
strSchema = strSchema.normalize();
strSchema = strSchema.normalize('NFKC');
namespace common {
strSchema = strSchema.allow(x);