Class TextValidationBuilder

TextValidationBuilder

A DataValidationBuilder for a TextValidation.

// Add a text item to a form and require it to be a number within a range.
const form = FormApp.create('My form');
const textItem =
    form.addTextItem().setTitle('Pick a number between 1 and 100?');
const textValidation =
    FormApp.createTextValidation()
        .setHelpText('Input was not a number between 1 and 100.')
        .requireNumberBetween(1, 100)
        .build();
textItem.setValidation(textValidation);

Methods

MethodReturn typeBrief description
requireNumber()TextValidationBuilderRequires text item to be a number.
requireNumberBetween(start, end)TextValidationBuilderRequires text item to be a number between start and end, inclusive.
requireNumberEqualTo(number)TextValidationBuilderRequires text item to be a number equal to value specified.
requireNumberGreaterThan(number)TextValidationBuilderRequires text item to be a number greater than the value specified.
requireNumberGreaterThanOrEqualTo(number)TextValidationBuilderRequires text item to be a number greater than or equal to the value specified.
requireNumberLessThan(number)TextValidationBuilderRequires text item to be a number less than the value specified.
requireNumberLessThanOrEqualTo(number)TextValidationBuilderRequires text item to be a number less than or equal to the value specified.
requireNumberNotBetween(start, end)TextValidationBuilderRequires text item to be a number not between start and end, inclusive.
requireNumberNotEqualTo(number)TextValidationBuilderRequires text item to be a number not equal to the value specified.
requireTextContainsPattern(pattern)TextValidationBuilderRequires response to contain pattern.
requireTextDoesNotContainPattern(pattern)TextValidationBuilderRequires response to not contain pattern.
requireTextDoesNotMatchPattern(pattern)TextValidationBuilderRequires response to not match pattern.
requireTextIsEmail()TextValidationBuilderRequires text item to be an email address.
requireTextIsUrl()TextValidationBuilderRequires text item to be a URL.
requireTextLengthGreaterThanOrEqualTo(number)TextValidationBuilderRequires response length to be greater than or equal to value.
requireTextLengthLessThanOrEqualTo(number)TextValidationBuilderRequires response length to be less than value.
requireTextMatchesPattern(pattern)TextValidationBuilderRequires response to match pattern.
requireWholeNumber()TextValidationBuilderRequires text item to be a whole number.

Detailed documentation

requireNumber()

Requires text item to be a number.

Return

TextValidationBuilder — this TextValidation, for chaining


requireNumberBetween(start, end)

Requires text item to be a number between start and end, inclusive.

Parameters

NameTypeDescription
startNumberthe lower bounds of the inclusive range
endNumberthe upper bounds of the inclusive range

Return

TextValidationBuilder — this TextValidation, for chaining


requireNumberEqualTo(number)

Requires text item to be a number equal to value specified.

Parameters

NameTypeDescription
numberNumberthe value which the item must be equal to.

Return

TextValidationBuilder — this TextValidation, for chaining


requireNumberGreaterThan(number)

Requires text item to be a number greater than the value specified.

Parameters

NameTypeDescription
numberNumberthe value which the item must be greater than.

Return

TextValidationBuilder — this TextValidation, for chaining


requireNumberGreaterThanOrEqualTo(number)

Requires text item to be a number greater than or equal to the value specified.

Parameters

NameTypeDescription
numberNumberthe value which the item must be greater than or equal to.

Return

TextValidationBuilder — this TextValidation, for chaining


requireNumberLessThan(number)

Requires text item to be a number less than the value specified.

Parameters

NameTypeDescription
numberNumberthe value which the item must be greater than.

Return

TextValidationBuilder — this TextValidation, for chaining


requireNumberLessThanOrEqualTo(number)

Requires text item to be a number less than or equal to the value specified.

Parameters

NameTypeDescription
numberNumberthe value which the item must be less than or equal to.

Return

TextValidationBuilder — this TextValidation, for chaining


requireNumberNotBetween(start, end)

Requires text item to be a number not between start and end, inclusive.

Parameters

NameTypeDescription
startNumberthe lower bounds of the inclusive range
endNumberthe upper bounds of the inclusive range

Return

TextValidationBuilder — this TextValidation, for chaining


requireNumberNotEqualTo(number)

Requires text item to be a number not equal to the value specified.

Parameters

NameTypeDescription
numberNumberthe value which the item must not be equal to.

Return

TextValidationBuilder — this TextValidation, for chaining


requireTextContainsPattern(pattern)

Requires response to contain pattern.

Parameters

NameTypeDescription
patternStringtext must contain pattern

Return

TextValidationBuilder — this for chaining


requireTextDoesNotContainPattern(pattern)

Requires response to not contain pattern.

Parameters

NameTypeDescription
patternStringtext must not contain pattern

Return

TextValidationBuilder — this for chaining


requireTextDoesNotMatchPattern(pattern)

Requires response to not match pattern.

Parameters

NameTypeDescription
patternStringtext must not match pattern

Return

TextValidationBuilder — this for chaining


requireTextIsEmail()

Requires text item to be an email address.

Return

TextValidationBuilder — this TextValidation, for chaining


requireTextIsUrl()

Requires text item to be a URL.

Return

TextValidationBuilder — this TextValidation, for chaining


requireTextLengthGreaterThanOrEqualTo(number)

Requires response length to be greater than or equal to value.

Parameters

NameTypeDescription
numberIntegerparagraph text length must be greater than this value

Return

TextValidationBuilder — this for chaining


requireTextLengthLessThanOrEqualTo(number)

Requires response length to be less than value.

Parameters

NameTypeDescription
numberIntegerparagraph text length must be less than or equal to this value

Return

TextValidationBuilder — this for chaining


requireTextMatchesPattern(pattern)

Requires response to match pattern.

Parameters

NameTypeDescription
patternStringtext must match pattern

Return

TextValidationBuilder — this for chaining


requireWholeNumber()

Requires text item to be a whole number.

Return

TextValidationBuilder — this TextValidation, for chaining