Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8035161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T02:13:50+00:00 2026-06-05T02:13:50+00:00

Right now I have a viewmodel that contains three lists of inputs; textboxinput, dropdownlistinput,

  • 0

Right now I have a viewmodel that contains three lists of inputs; textboxinput, dropdownlistinput, and checkboxinput. Each of these lists is a list of input objects, which contain four values; paramenums, paramname, paramtype, and value. I am using these input lists to generate a variable number of fields on a form dependent on how many objects each list contains.

My current problem is that I’m not sure how to validate the variables in the list objects with fluent validation. I know how the behavior of each list should behave with regards to returning Nothing, but I don’t know how to code that behavior with FluentValidation.

Input Model:

Public Class Input
    Property value As String
    Property ParamName As String
    Property ParamType As String
    Property ParamEnums As List(Of String)
End Class

ParamViewModel:

Imports FluentValidation
Imports FluentValidation.Attributes

<Validator(GetType(ParamViewModelValidator))> _
Public Class ParamViewModel
    Property TextBoxInput As List(Of Input)
    Property DropdownListInput As List(Of Input)
    Property CheckBoxInput As List(Of Input)
End Class

My View:

@Modeltype SensibleScriptRunner.ParamViewModel

<h2>Assign Values to Each Parameter</h2>

@Code
    Using (Html.BeginForm("Index", "Parameter", FormMethod.Post))
    @<div> 
        <fieldset>
            <legend>Parameter List</legend>
            @For i = 0 To (Model.TextBoxInput.Count - 1)
                    Dim iterator = i
                    @Html.EditorFor(Function(x) x.TextBoxInput(iterator), "TextInput")
            Next
            @For i = 0 To Model.DropdownListInput.Count - 1
                    Dim iterator = i
                    @Html.EditorFor(Function(x) x.DropdownListInput(iterator), "EnumInput")
            Next
            @For i = 0 To Model.CheckBoxInput.Count - 1
                    Dim iterator = i
                    @Html.EditorFor(Function(x) x.CheckBoxInput(iterator), "CheckBoxInput")
            Next
            <p>
                <input type="submit" value="Query Server"/>
            </p>
        </fieldset>
    </div>
    Html.EndForm()
    End Using
End Code

Example of one of the Editor templates:

@modeltype SensibleScriptRunner.Input

@Code
    @<div class="editor-label">
        @Html.LabelFor(Function(v) v.value, Model.ParamName)
    </div>
    @<div class="editor-field">
        @Html.TextBoxFor(Function(v) v.value)
    </div>
End Code

Current FluentValidation Code:

Imports FluentValidation

Public Class ParamViewModelValidator
    Inherits AbstractValidator(Of ParamViewModel)

    Public Sub New()
        RuleFor(Function(x) x.TextBoxInput).NotEmpty.[When](Function(x) Not IsNothing(x.TextBoxInput))
        RuleFor(Function(x) x.DropdownListInput).NotEmpty.[When](Function(x) Not IsNothing(x.DropdownListInput))
        RuleFor(Function(x) x.CheckBoxInput).NotEmpty.[When](Function(x) Not IsNothing(x.CheckBoxInput))
    End Sub

End Class

The thing I want to currently do is confirm that in every object in each of my lists, they all have a value attribute that isn’t nothing. Can I do this by validating the input model? Right now, the code works at confirming that the list itself isn’t null, but the objects in the list can still contain all null values. Is there a trivial way to do this?

Alternatively, should I have set my code up differently?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T02:13:52+00:00Added an answer on June 5, 2026 at 2:13 am

    Well, I figured it out. For anyone who is curious, all I had to do was add an inputvalidator class.

    Imports FluentValidation
    
    Public Class InputValidator
    Inherits AbstractValidator(Of Input)
    
    Public Sub New()
        RuleFor(Function(x) x.value).NotEmpty()
        RuleFor(Function(x) x.ParamName).NotEmpty()
        RuleFor(Function(x) x.ParamType).NotEmpty()
    End Sub
    
    End Class
    

    Adding this to my input model solved all the problems. I’m not sure where the code actually checks this validation (my editor templates point to input as the model, perhaps that has something to do with it; it could also be that when my paramviewmodelvalidator checks to see if a list is valid, it also checks the criteria of each object in that list (I’m thinking it’s this one)). Regardless, here’s a solution if anyone has a similar problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Right now I have these buttons that line up nicely, but they have some
Right now I have a tableview, and I can assure you that the delegate
Good day! I right now have a function the drags an element from a
Right now I have to pull up Pending Changes window, right-click on the file
Right now I have some functionality working but its really ugly and I know
Right now I have this layout: <?xml version=1.0 encoding=utf-8?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android android:orientation=vertical android:layout_width=fill_parent android:layout_height=fill_parent
Right now I have an UIScrollView, which has a lot of UIImageViews, UILabels and
Right now I have this jQuery('.widget-prop').keyup(function() { var prop = jQuery(this).attr('id'); var val =
Right now I have tornado options in same file, as in tornado app. And
Right now I have this SQL query which is valid but always times out:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.