How to get validation pattern from Google Form item










1















In Google Forms, a question/item of class TextItem can have a validation pattern set (i.e., the response must match the pattern to be accepted by the form) by doing something like:



var textValidation = FormApp.createTextValidation()
.requireTextMatchesPattern(my_regex_pattern)
.build();
textItem.setValidation(textValidation);


I would like to read that pattern from an existing textItem (in order to have a script go through several questions with unique patterns and save them), but I cannot find any references to relevant methods or properties for validation rules, e.g. (made-up examples):



var existing_pattern = textItem.getTextMatchesPattern();


or



var existing_patern = textItem.getValidation.getTextMatchesPattern();


From what I can see, it looks like this is not actually possible, but that seems quite strange. Am I missing something?



Note: Using the Web interface, it's trivial to get the pattern for a given question/item. I'm specifically asking how to get it through a script.










share|improve this question
























  • Also explain exactly why you need access to the pattern?

    – TheMaster
    Nov 15 '18 at 0:40











  • @TheMaster, I have a large number of items with unique patterns, and I wanted to have a script export them to a separate sheet.

    – Ratler
    Nov 15 '18 at 18:36











  • so do you intent to restrict the user to fill out a field with only a specific pattern, or do you want to study the pattern text once they have filled them out.

    – Narendra
    Nov 15 '18 at 22:36











  • if the text validation is too restricted. you can choose to not put text validation here. Instead study the pattern when you are getting the response after form submission. there you would have a lot more freedom

    – Narendra
    Nov 15 '18 at 22:37











  • @Narendra, restrict: each question has a very precise definition of accepted answers. I'm just trying to read that pattern.

    – Ratler
    Nov 17 '18 at 1:31















1















In Google Forms, a question/item of class TextItem can have a validation pattern set (i.e., the response must match the pattern to be accepted by the form) by doing something like:



var textValidation = FormApp.createTextValidation()
.requireTextMatchesPattern(my_regex_pattern)
.build();
textItem.setValidation(textValidation);


I would like to read that pattern from an existing textItem (in order to have a script go through several questions with unique patterns and save them), but I cannot find any references to relevant methods or properties for validation rules, e.g. (made-up examples):



var existing_pattern = textItem.getTextMatchesPattern();


or



var existing_patern = textItem.getValidation.getTextMatchesPattern();


From what I can see, it looks like this is not actually possible, but that seems quite strange. Am I missing something?



Note: Using the Web interface, it's trivial to get the pattern for a given question/item. I'm specifically asking how to get it through a script.










share|improve this question
























  • Also explain exactly why you need access to the pattern?

    – TheMaster
    Nov 15 '18 at 0:40











  • @TheMaster, I have a large number of items with unique patterns, and I wanted to have a script export them to a separate sheet.

    – Ratler
    Nov 15 '18 at 18:36











  • so do you intent to restrict the user to fill out a field with only a specific pattern, or do you want to study the pattern text once they have filled them out.

    – Narendra
    Nov 15 '18 at 22:36











  • if the text validation is too restricted. you can choose to not put text validation here. Instead study the pattern when you are getting the response after form submission. there you would have a lot more freedom

    – Narendra
    Nov 15 '18 at 22:37











  • @Narendra, restrict: each question has a very precise definition of accepted answers. I'm just trying to read that pattern.

    – Ratler
    Nov 17 '18 at 1:31













1












1








1








In Google Forms, a question/item of class TextItem can have a validation pattern set (i.e., the response must match the pattern to be accepted by the form) by doing something like:



var textValidation = FormApp.createTextValidation()
.requireTextMatchesPattern(my_regex_pattern)
.build();
textItem.setValidation(textValidation);


I would like to read that pattern from an existing textItem (in order to have a script go through several questions with unique patterns and save them), but I cannot find any references to relevant methods or properties for validation rules, e.g. (made-up examples):



var existing_pattern = textItem.getTextMatchesPattern();


or



var existing_patern = textItem.getValidation.getTextMatchesPattern();


From what I can see, it looks like this is not actually possible, but that seems quite strange. Am I missing something?



Note: Using the Web interface, it's trivial to get the pattern for a given question/item. I'm specifically asking how to get it through a script.










share|improve this question
















In Google Forms, a question/item of class TextItem can have a validation pattern set (i.e., the response must match the pattern to be accepted by the form) by doing something like:



var textValidation = FormApp.createTextValidation()
.requireTextMatchesPattern(my_regex_pattern)
.build();
textItem.setValidation(textValidation);


I would like to read that pattern from an existing textItem (in order to have a script go through several questions with unique patterns and save them), but I cannot find any references to relevant methods or properties for validation rules, e.g. (made-up examples):



var existing_pattern = textItem.getTextMatchesPattern();


or



var existing_patern = textItem.getValidation.getTextMatchesPattern();


From what I can see, it looks like this is not actually possible, but that seems quite strange. Am I missing something?



Note: Using the Web interface, it's trivial to get the pattern for a given question/item. I'm specifically asking how to get it through a script.







google-apps-script google-form






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 15 '18 at 18:34







Ratler

















asked Nov 15 '18 at 0:16









RatlerRatler

707




707












  • Also explain exactly why you need access to the pattern?

    – TheMaster
    Nov 15 '18 at 0:40











  • @TheMaster, I have a large number of items with unique patterns, and I wanted to have a script export them to a separate sheet.

    – Ratler
    Nov 15 '18 at 18:36











  • so do you intent to restrict the user to fill out a field with only a specific pattern, or do you want to study the pattern text once they have filled them out.

    – Narendra
    Nov 15 '18 at 22:36











  • if the text validation is too restricted. you can choose to not put text validation here. Instead study the pattern when you are getting the response after form submission. there you would have a lot more freedom

    – Narendra
    Nov 15 '18 at 22:37











  • @Narendra, restrict: each question has a very precise definition of accepted answers. I'm just trying to read that pattern.

    – Ratler
    Nov 17 '18 at 1:31

















  • Also explain exactly why you need access to the pattern?

    – TheMaster
    Nov 15 '18 at 0:40











  • @TheMaster, I have a large number of items with unique patterns, and I wanted to have a script export them to a separate sheet.

    – Ratler
    Nov 15 '18 at 18:36











  • so do you intent to restrict the user to fill out a field with only a specific pattern, or do you want to study the pattern text once they have filled them out.

    – Narendra
    Nov 15 '18 at 22:36











  • if the text validation is too restricted. you can choose to not put text validation here. Instead study the pattern when you are getting the response after form submission. there you would have a lot more freedom

    – Narendra
    Nov 15 '18 at 22:37











  • @Narendra, restrict: each question has a very precise definition of accepted answers. I'm just trying to read that pattern.

    – Ratler
    Nov 17 '18 at 1:31
















Also explain exactly why you need access to the pattern?

– TheMaster
Nov 15 '18 at 0:40





Also explain exactly why you need access to the pattern?

– TheMaster
Nov 15 '18 at 0:40













@TheMaster, I have a large number of items with unique patterns, and I wanted to have a script export them to a separate sheet.

– Ratler
Nov 15 '18 at 18:36





@TheMaster, I have a large number of items with unique patterns, and I wanted to have a script export them to a separate sheet.

– Ratler
Nov 15 '18 at 18:36













so do you intent to restrict the user to fill out a field with only a specific pattern, or do you want to study the pattern text once they have filled them out.

– Narendra
Nov 15 '18 at 22:36





so do you intent to restrict the user to fill out a field with only a specific pattern, or do you want to study the pattern text once they have filled them out.

– Narendra
Nov 15 '18 at 22:36













if the text validation is too restricted. you can choose to not put text validation here. Instead study the pattern when you are getting the response after form submission. there you would have a lot more freedom

– Narendra
Nov 15 '18 at 22:37





if the text validation is too restricted. you can choose to not put text validation here. Instead study the pattern when you are getting the response after form submission. there you would have a lot more freedom

– Narendra
Nov 15 '18 at 22:37













@Narendra, restrict: each question has a very precise definition of accepted answers. I'm just trying to read that pattern.

– Ratler
Nov 17 '18 at 1:31





@Narendra, restrict: each question has a very precise definition of accepted answers. I'm just trying to read that pattern.

– Ratler
Nov 17 '18 at 1:31












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310691%2fhow-to-get-validation-pattern-from-google-form-item%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53310691%2fhow-to-get-validation-pattern-from-google-form-item%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto