Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
      • About the DevOps Program
      • DataMiner DevOps Support
  • Downloads
  • More
    • DataMiner Releases & Updates
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

Best way to filter/sanitize user text input in an AS or a parameter edit?

Solved438 views5th July 2023Test input validation
3
Jeff Douglass860 14th May 2023 0 Comments

We have element Parameters and Automation scripts that are used dynamically to create various DM items such as elements and services and as such they should not allow a user to use characters that DM does not allow for such items. What would be the best way to filter user text input in an automation script and for a parameter edit to not allow characters considered invalid by DM for such item names? Would using c# regex object with IsMatch() routine the best way or is there a better way. Can someone please provide an example.

Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 5th July 2023

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
0
Michiel Saelen [SLC] [DevOps Enabler]5.63K Posted 19th May 2023 2 Comments

Hi Jeff,

The DataMinerSystems Library is the best way to perform such actions in your DataMiner system. It is a public NuGet library and can be used for Protocols, Automation, or other C# apps. To do this from automation or Qactions (Protocols) there are dedicated libraries:

  • Skyline.DataMiner.Core.DataMinerSystem.Automation
  • Skyline.DataMiner.Core.DataMinerSystem.Protocol

Some example code to create a view to get you started (you can return the message of the ArgumentException for detailed info to the user):

Marieke Goethals [SLC] [DevOps Catalyst] Selected answer as best 5th July 2023
Jeff Douglass commented 19th May 2023

Thank you for the info Michiel, I will take a look at this. I was able to come up with a solution utilizing C#’s Regex capabilities. It is not the most elegant solution as It does not allow for validation logic to be applied at/during the character input level, but does allow for the final resulting string to get validated. It also requires that the validation logic/code get added to every script and protocol at every point where validation is required which can require a lot of changes throughout a system depending on how many parameters need to get validated and where the validation needs to take place.

Jeff Douglass commented 19th May 2023

Here is an example of what I am doing for anyone that is interested. This is added to a script that prompts the user for various items that will eventually be used to update SNMP devices. Once the user tries move to the next step in the process the inputted string is validated and any characters that match the list in the Regex string are replaced with ‘?’ and an error message is presented to the user telling them that the string they inputted contains invalid characters.

Hope this helps someone else.

String NameFilterString = @”[^ -~]|[/\:;*?””\|!%]”;
Regex MyregEx = new Regex(NameFilterString);

if(MyregEx.IsMatch(user inputted string ))//jdd
{
user inputted string = MyregEx.Replace(data.CapacityGroup.Name,”?”);
errors[“name”]= “ERROR: Invalid Name”;
}

You are viewing 1 out of 1 answers, click here to view all answers.
Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs

[ Placeholder content for popup link ] WordPress Download Manager - Best Download Management Plugin