PINE LIBRARY
ScaleValidator

🛡️ ScaleValidator Library - Input Validation for PineScript
📢 ABOUT
ScaleValidator is a lightweight utility library that provides robust input validation for PineScript. It ensures your scripts receive valid arguments and throws helpful runtime errors when they don't.
✨ FEATURES
🛡️ Validation Methods
Validate inputs and throw descriptive runtime errors if invalid:
• isValidLocation() — Validate location strings
• isValidPosition() — Validate position strings
• isValidFormat() — Validate format strings
• isValidPOV() — Validate point-of-view (extend) strings
🔍 Helper Methods
Quick boolean checks without throwing errors:
• isLocationAbove() / isLocationBelow() — Check vertical location
• isPositionAbove() / isPositionCenter() / isPositionBelow() — Check position row
• isPositionLeft() / isPositionRight() — Check position column
💡 USAGE EXAMPLE
Pine Script®
📊 VALID CONSTANTS REFERENCE
Locations
• location.top — Top of pane
• location.bottom — Bottom of pane
• location.abovebar — Above price bar
• location.belowbar — Below price bar
• location.absolute — Absolute position
Positions (3x3 Grid)
• Top Row: top_left, top_center, top_right
• Middle Row: middle_left, middle_center, middle_right
• Bottom Row: bottom_left, bottom_center, bottom_right
Formats
• format.inherit — Inherit from parent
• format.percent — Percentage format
Point of View (Extend)
• extend.both — Extend in both directions
• extend.left — Extend to the left
• extend.right — Extend to the right
🔧 METHOD REFERENCE
Validators (throw runtime error if invalid)
• isValidLocation(string) → bool
• isValidPosition(string) → bool
• isValidFormat(string) → bool
• isValidPOV(string) → bool
Helpers (return bool, no errors)
• isLocationAbove(string) → bool
• isLocationBelow(string) → bool
• isPositionAbove(string) → bool
• isPositionCenter(string) → bool
• isPositionBelow(string) → bool
• isPositionLeft(string) → bool
• isPositionRight(string) → bool
🚀 WHY USE THIS?
• 🛡️ Defensive Programming — Catch invalid inputs early
• 📖 Helpful Errors — Descriptive messages show valid options
• ⚡ Lightweight — No dependencies, minimal overhead
• 🔗 Companion to ScalesDEV — Used internally by the Scale library
📋 CHANGELOG
✅ Added method badges (helper/validator)
✅ Created reference tables for valid constants
✅ Improved parameter descriptions
✅ Formatted return types
🙏 RELATED LIBRARIES
Check out Scales for building beautiful scale visualizations that use this validator!
Battries included! 🔋Happy coding! 🚀 cryptolinx for the TradingView community
📢 ABOUT
ScaleValidator is a lightweight utility library that provides robust input validation for PineScript. It ensures your scripts receive valid arguments and throws helpful runtime errors when they don't.
✨ FEATURES
🛡️ Validation Methods
Validate inputs and throw descriptive runtime errors if invalid:
• isValidLocation() — Validate location strings
• isValidPosition() — Validate position strings
• isValidFormat() — Validate format strings
• isValidPOV() — Validate point-of-view (extend) strings
🔍 Helper Methods
Quick boolean checks without throwing errors:
• isLocationAbove() / isLocationBelow() — Check vertical location
• isPositionAbove() / isPositionCenter() / isPositionBelow() — Check position row
• isPositionLeft() / isPositionRight() — Check position column
💡 USAGE EXAMPLE
📊 VALID CONSTANTS REFERENCE
Locations
• location.top — Top of pane
• location.bottom — Bottom of pane
• location.abovebar — Above price bar
• location.belowbar — Below price bar
• location.absolute — Absolute position
Positions (3x3 Grid)
• Top Row: top_left, top_center, top_right
• Middle Row: middle_left, middle_center, middle_right
• Bottom Row: bottom_left, bottom_center, bottom_right
Formats
• format.inherit — Inherit from parent
• format.percent — Percentage format
Point of View (Extend)
• extend.both — Extend in both directions
• extend.left — Extend to the left
• extend.right — Extend to the right
🔧 METHOD REFERENCE
Validators (throw runtime error if invalid)
• isValidLocation(string) → bool
• isValidPosition(string) → bool
• isValidFormat(string) → bool
• isValidPOV(string) → bool
Helpers (return bool, no errors)
• isLocationAbove(string) → bool
• isLocationBelow(string) → bool
• isPositionAbove(string) → bool
• isPositionCenter(string) → bool
• isPositionBelow(string) → bool
• isPositionLeft(string) → bool
• isPositionRight(string) → bool
🚀 WHY USE THIS?
• 🛡️ Defensive Programming — Catch invalid inputs early
• 📖 Helpful Errors — Descriptive messages show valid options
• ⚡ Lightweight — No dependencies, minimal overhead
• 🔗 Companion to ScalesDEV — Used internally by the Scale library
📋 CHANGELOG
✅ Added method badges (helper/validator)
✅ Created reference tables for valid constants
✅ Improved parameter descriptions
✅ Formatted return types
🙏 RELATED LIBRARIES
Check out Scales for building beautiful scale visualizations that use this validator!
Battries included! 🔋Happy coding! 🚀 cryptolinx for the TradingView community
Bibliothèque Pine
Dans l'esprit TradingView, l'auteur a publié ce code Pine sous forme de bibliothèque open source afin que d'autres programmeurs Pine de notre communauté puissent le réutiliser. Bravo à l'auteur! Vous pouvez utiliser cette bibliothèque à titre privé ou dans d'autres publications open source, mais la réutilisation de ce code dans des publications est régie par nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.
Bibliothèque Pine
Dans l'esprit TradingView, l'auteur a publié ce code Pine sous forme de bibliothèque open source afin que d'autres programmeurs Pine de notre communauté puissent le réutiliser. Bravo à l'auteur! Vous pouvez utiliser cette bibliothèque à titre privé ou dans d'autres publications open source, mais la réutilisation de ce code dans des publications est régie par nos Règles.
Clause de non-responsabilité
Les informations et publications ne sont pas destinées à être, et ne constituent pas, des conseils ou recommandations financiers, d'investissement, de trading ou autres fournis ou approuvés par TradingView. Pour en savoir plus, consultez les Conditions d'utilisation.