Stay organized with collections
Save and categorize content based on your preferences.
blockly > FieldVariable > getValidator
FieldVariable.getValidator() method
Gets the validation function for this field, or null if not set. Returns null if the variable is not set, because validators should not run on the initial setValue call, because the field won't be attached to a block and workspace at that point.
Signature:
getValidator(): FieldVariableValidator | null;
Returns:
FieldVariableValidator | null
Validation function, or null.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-18 UTC."],[[["\u003cp\u003eThe \u003ccode\u003egetValidator()\u003c/code\u003e method retrieves the validation function associated with a FieldVariable, which determines if a variable assignment is valid.\u003c/p\u003e\n"],["\u003cp\u003eIt returns \u003ccode\u003enull\u003c/code\u003e if the variable isn't set or if the validation function hasn't been assigned, preventing validation during initial value setting.\u003c/p\u003e\n"],["\u003cp\u003eThe returned validation function, if present, is of the \u003ccode\u003eFieldVariableValidator\u003c/code\u003e type and will be executed when variable assignments occur.\u003c/p\u003e\n"]]],[],null,["[blockly](./blockly.md) \\\u003e [FieldVariable](./blockly.fieldvariable_class.md) \\\u003e [getValidator](./blockly.fieldvariable_class.getvalidator_1_method.md)\n\nFieldVariable.getValidator() method\n-----------------------------------\n\nGets the validation function for this field, or null if not set. Returns null if the variable is not set, because validators should not run on the initial setValue call, because the field won't be attached to a block and workspace at that point.\n\n**Signature:** \n\n getValidator(): FieldVariableValidator | null;\n\n**Returns:**\n\n[FieldVariableValidator](./blockly.fieldvariablevalidator_typealias.md) \\| null\n\nValidation function, or null."]]