# Is er een manier om een min en max op te geven voor settings.yml voor een plugin?

**URL:** https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676
**Category:** Development
**Created:** [28 maart 2023 om 10:35 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676 "2023-03-28T10:35:22Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![bstgmr02](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bstgmr02](https://meta.discourse.org/u/bstgmr02)
#### Post date: [28 maart 2023 om 10:35 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676/1 "2023-03-28T10:35:22Z")

</div>

// Running Discourse Development Environment //

I have the following:

```plaintext
min_score:
    default: 0.01
    client: true
    min: 0.0001

```

But the admin can keep overwriting it to negative values, is there a workaround for this?

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [28 maart 2023 om 17:29 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676/2 "2023-03-28T17:29:33Z")

</div>

I could not reproduce your setting as it is:

![image](https://global.discourse-cdn.com/meta/original/4X/f/b/e/fbeaf0abe247287454143a4d2a7d2235939902af.png)

Can you try adding `type: float`?  
I’m not sure it’s required, as I believe basic types are guessed automatically.

---

<div class="post-metadata">

### Author: ![bstgmr02](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bstgmr02](https://meta.discourse.org/u/bstgmr02)
#### Post date: [29 maart 2023 om 08:02 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676/3 "2023-03-29T08:02:07Z")

</div>

I did try the `type: float` too but sadly it had no affect:

```plaintext
 min_score:
    default: 0.01
    client: true
    min: 0.0001
    type: float

```

 ![image](https://global.discourse-cdn.com/meta/original/4X/1/a/e/1aed1ec9fcd7fa6c5ca45aeee4b13a4fdbccd643.png)

---

<div class="post-metadata">

### Author: ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)
#### Post date: [29 maart 2023 om 11:33 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676/4 "2023-03-29T11:33:07Z")

</div>

Your screenshot is not showing the `minimum_tip` setting.

---

<div class="post-metadata">

### Author: ![bstgmr02](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bstgmr02](https://meta.discourse.org/u/bstgmr02)
#### Post date: [29 maart 2023 om 11:36 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676/5 "2023-03-29T11:36:30Z")

</div>

Was just a typo in my post, has been updated. Issue still remains.

---

<div class="post-metadata">

### Author: ![bstgmr02](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bstgmr02](https://meta.discourse.org/u/bstgmr02)
#### Post date: [29 maart 2023 om 14:12 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676/6 "2023-03-29T14:12:43Z")

</div>

Weird thing is that it resets the value to back to `0.0` when I enter an invalid number but only upon refreshing. But no errors are appearing on the UI side either way.

---

<div class="post-metadata">

### Author: ![bstgmr02](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bstgmr02](https://meta.discourse.org/u/bstgmr02)
#### Post date: [30 maart 2023 om 10:09 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676/7 "2023-03-30T10:09:31Z")

</div>

Bump.

Custom validation seems to work and error out, however I have no luck with the default validation of min/max.

Anyone have any ideas?

---

<div class="post-metadata">

### Author: ![bstgmr02](https://avatars.discourse-cdn.com/v4/letter/b/858c86/32.png) [@bstgmr02](https://meta.discourse.org/u/bstgmr02)
#### Post date: [30 maart 2023 om 10:31 UTC](https://meta.discourse.org/t/is-there-a-way-to-specify-a-min-and-max-for-settings-yml-for-a-plugin/259676/8 "2023-03-30T10:31:04Z")

</div>

After some further testing, it seems like it does not work for `type: float`, and only works for `type: integer`. However, a user can freely input anything apart from an integer - which requires a hard refresh and results in the value resetting to 0.

Seems like a bug/error on Discourse’s side? It also seems to affect the Chat plugin.
