question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is your feature request related to a problem? Please describe. In our project, we need to validate settings values when modified through the Django admin UI. E.g. for an integer field, we would like to validate the value to be positive.

Right now the package doesn’t provide positive integer field type or validators.

Describe the solution you’d like

# A solution with a validator parameter that accepts a function
months = Setting(
        name="MONTHS",
        value_type=Setting.TYPE_INT,
        value=48,
        description="Number of months.",
        validator=lambda x: x>0,
    )
months.save()

Describe alternatives you’ve considered

# A solution based on native datatypes 
# this can't be supported by all dbs: 
# i.e. PostgreSQL does not have an unsigned integer
months = Setting(
        name="MONTHS",
        value_type=Setting.TYPE_POSITIVE_INT,
        value=48,
        description="Number of months.",
    )
months.save()

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:14 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
domeniconappocommented, Sep 23, 2022

Hi @fabiocaccamo Thank you so much! Also for latest improvements and the addition to the README.

No, I don’t think the validator path would be useful in the changelist.

Thank you again. We will update to 0.6 soon.

1reaction
fabiocaccamocommented, Sep 27, 2022

@domeniconappo you can upgrade to 0.6.1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Validators - Angular
A validator is a function that processes a FormControl or collection of controls and returns an error map or null. A null map...
Read more >
The W3C Markup Validation Service
This validator checks the markup validity of Web documents in HTML, XHTML, SMIL, MathML, etc. If you wish to validate specific content such...
Read more >
validators — validators 0.11.2 documentation
Each validator in validators is a simple function that takes the value to validate and possibly some additional key-value arguments.
Read more >
Validator - Wikipedia
A validator is a computer program used to check the validity or syntactical correctness of a fragment of code or document. The term...
Read more >
Custom Form Validators • Angular - codecraft.tv
A validator in Angular is a function which returns null if a control is valid or an error object if it's invalid. For...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found