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
ספריית Pine
ברוח האמיתית של TradingView, המחבר לפרסם את הקוד של Pine הזה כספרייה בקוד פתוח, כך שמתכנתים אחרים בקהילתנו יעשו שימוש חוזר. כל הכבוד למחבר! ניתן להשתמש בספרייה הזו באופן פרטי או בומים בקוד פתוח, אך השימוש בחוזר בקוד הזה בפרסומים כפוף ל-כללי הבית.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.
ספריית Pine
ברוח האמיתית של TradingView, המחבר לפרסם את הקוד של Pine הזה כספרייה בקוד פתוח, כך שמתכנתים אחרים בקהילתנו יעשו שימוש חוזר. כל הכבוד למחבר! ניתן להשתמש בספרייה הזו באופן פרטי או בומים בקוד פתוח, אך השימוש בחוזר בקוד הזה בפרסומים כפוף ל-כללי הבית.
כתב ויתור
המידע והפרסומים אינם מיועדים להיות, ואינם מהווים, ייעוץ או המלצה פיננסית, השקעתית, מסחרית או מכל סוג אחר המסופקת או מאושרת על ידי TradingView. קרא עוד ב־תנאי השימוש.