Stay organized with collections
Save and categorize content based on your preferences.
blockly > FieldNumber > setConstraints
FieldNumber.setConstraints() method
Set the maximum, minimum and precision constraints on this field. Any of these properties may be undefined or NaN to be disabled. Setting precision (usually a power of 10) enforces a minimum step between values. That is, the user's value will rounded to the closest multiple of precision. The least significant digit place is inferred from the precision. Integers values can be enforces by choosing an integer precision.
Signature:
setConstraints(min: number | string | undefined | null, max: number | string | undefined | null, precision: number | string | undefined | null): void;
Parameters
Parameter |
Type |
Description |
min |
number | string | undefined | null |
Minimum value. |
max |
number | string | undefined | null |
Maximum value. |
precision |
number | string | undefined | null |
Precision for value. |
Returns:
void
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."],[[["`FieldNumber.setConstraints()` allows you to define minimum, maximum, and precision restrictions for a number field in Blockly."],["Setting the `precision` parameter rounds the user's input to the nearest multiple of the defined value, effectively controlling the minimum step between values."],["Any of the constraint parameters (`min`, `max`, `precision`) can be set to `undefined` or `NaN` to disable that specific restriction."]]],["The `setConstraints` method in `FieldNumber` sets constraints for a numeric field. It accepts `min`, `max`, and `precision` as parameters, which define the minimum allowed value, the maximum allowed value, and the value precision, respectively. These parameters can be numbers, strings, undefined, or null. Precision enforces a minimum step, rounding the user's input to the nearest multiple. Any constraint can be disabled by setting it to undefined or NaN. The method returns nothing.\n"]]