# Validating Persistent Record Fields and using feedback panel to show errors

**URL:** <https://forum.inductiveautomation.com/t/validating-persistent-record-fields-and-using-feedback-panel-to-show-errors/104721>\
**Category:** Module Development\
**Created:** [April 4, 2025, 3:11pm UTC](https://forum.inductiveautomation.com/t/validating-persistent-record-fields-and-using-feedback-panel-to-show-errors/104721 "2025-04-04T15:11:33Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![prashanta.shrestha](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/prashanta.shrestha/32/20575_2.png) [@prashanta.shrestha](https://forum.inductiveautomation.com/u/prashanta.shrestha)\
**Post date:** [April 4, 2025, 3:11pm UTC](https://forum.inductiveautomation.com/t/validating-persistent-record-fields-and-using-feedback-panel-to-show-errors/104721/1 "2025-04-04T15:11:34Z")

</div>

I’m working on a gateway module that needs to store some properties as Persistence Records. I’m validating a StringField, and instead of throwing an exception that would cause the UI form to exit, I want to display a message on the feedback panel at the top of the form, to give the user a chance to fix the input. Something like this:

 ![Screenshot 2025-04-04 at 11.00.20 AM](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/7/5780a4b1f42128f45f77c29a5e24a5a3104549d4.png)

For context here is the snippet I am using:

```python
public static final StringField FooBar = new StringField(META, "FooBar")
      .addValidator(new SValidatorI() {
        @Override
        public void onValidate(SFieldMeta field, SRecordInstance instance) throws SException.Validation {
          Boolean isEnabledValue = instance.getBoolean(isEnabled);
          String foobarValue = instance.getString(field);

          if (isEnabledValue && (foobarValue == null || foobarValue.trim().isEmpty())) {            
            throw new SException.Validation("Foo bar cannot be null or empty when enabled.");
          }
        }
      });

```

Has anyone else encountered this before?

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 4, 2025, 3:17pm UTC](https://forum.inductiveautomation.com/t/validating-persistent-record-fields-and-using-feedback-panel-to-show-errors/104721/2 "2025-04-04T15:17:12Z")

</div>

You don't need a validator for that case, just create the StringField with `SFieldFlags.SMANDATORY` instead:

```python
public static final StringField HOSTNAME = 
   new StringField(META, "Hostname", SFieldFlags.SMANDATORY);

```

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 4, 2025, 3:19pm UTC](https://forum.inductiveautomation.com/t/validating-persistent-record-fields-and-using-feedback-panel-to-show-errors/104721/3 "2025-04-04T15:19:10Z")

</div>

When you do use a validator, implement `IValidator`, and call `IValidatable::error` when there's a validation error.

---

<div class="post-metadata">

**Author:** ![prashanta.shrestha](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/prashanta.shrestha/32/20575_2.png) [@prashanta.shrestha](https://forum.inductiveautomation.com/u/prashanta.shrestha)\
**Post date:** [April 4, 2025, 3:58pm UTC](https://forum.inductiveautomation.com/t/validating-persistent-record-fields-and-using-feedback-panel-to-show-errors/104721/4 "2025-04-04T15:58:01Z")

</div>

Thanks so much for the quick reply!

You’re right - `StringField` with `SFieldFlags.SMANDATORY` does work. However, in my case, the validation logic also needs to take into account the values of some other fields.

I didn’t come across `IValidator` in the SDK docs. Just to confirm, I’m working with SDK version 8.1.37.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [April 4, 2025, 4:13pm UTC](https://forum.inductiveautomation.com/t/validating-persistent-record-fields-and-using-feedback-panel-to-show-errors/104721/5 "2025-04-04T16:13:59Z")

</div>

It's part of Wicket, not part of our SDK docs.
