Class ParagraphTextValidationBuilder

  • ParagraphTextValidationBuilder is used to create validation rules for ParagraphTextValidation in Google Forms.

  • It offers methods to require or disallow specific text patterns within a response.

  • It can also enforce minimum or maximum text length requirements for responses.

  • The builder methods return the builder object, allowing for chaining multiple validation rules.

ParagraphTextValidationBuilder

A DataValidationBuilder for aParagraphTextValidation.

// Add a paragraph text item to a form and require the answer to be at least 100// characters.constform=FormApp.create('My Form');constparagraphTextItem=form.addParagraphTextItem().setTitle('Describe yourself:');constparagraphtextValidation=FormApp.createParagraphTextValidation().setHelpText('Answer must be more than 100 characters.').requireTextLengthGreaterThan(100);paragraphTextItem.setValidation(paragraphtextValidation);

Methods

MethodReturn typeBrief description
requireTextContainsPattern(pattern)ParagraphTextValidationBuilderRequires response to contain pattern.
requireTextDoesNotContainPattern(pattern)ParagraphTextValidationBuilderRequires response to not contain pattern.
requireTextDoesNotMatchPattern(pattern)ParagraphTextValidationBuilderRequires response to not match pattern.
requireTextLengthGreaterThanOrEqualTo(number)ParagraphTextValidationBuilderRequires response length to be greater than or equal to value.
requireTextLengthLessThanOrEqualTo(number)ParagraphTextValidationBuilderRequires response length to be less than value.
requireTextMatchesPattern(pattern)ParagraphTextValidationBuilderRequires response to match pattern.

Detailed documentation

requireTextContainsPattern(pattern)

Requires response to contain pattern.

Parameters

NameTypeDescription
patternStringtext must contain pattern

Return

ParagraphTextValidationBuilder — this for chaining


requireTextDoesNotContainPattern(pattern)

Requires response to not contain pattern.

Parameters

NameTypeDescription
patternStringtext must not contain pattern

Return

ParagraphTextValidationBuilder — this for chaining


requireTextDoesNotMatchPattern(pattern)

Requires response to not match pattern.

Parameters

NameTypeDescription
patternStringtext must not match pattern

Return

ParagraphTextValidationBuilder — this 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

ParagraphTextValidationBuilder — 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

ParagraphTextValidationBuilder — this for chaining


requireTextMatchesPattern(pattern)

Requires response to match pattern.

Parameters

NameTypeDescription
patternStringtext must match pattern

Return

ParagraphTextValidationBuilder — this for chaining

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-12-11 UTC.