Facebook
Twitter
Pinterest
Tumblr
GitHub
RSS
  • DEV Home
  • Documentation
  • Reference
  • Download
Search Results for

    Show / Hide Table of Contents

    Features: Input Constraints

    For some cases, constraints are automatically inferred. For example, whether an input is required or not can be controlled by using Nullable value types. For numbers, minimum and maximum values are automatically determined from the data type. Beyond those automatic constraints, it is also possible to use attributes for more detailed control.

    Text Input

    Required Text

    Empty text input can be prevented by adding a Required attribute. It is not possible to submit the form without having entering some text.

    [DisplayName("Required Text")]
    [Description("Empty text input can be prevented by adding a Required attribute. It is not possible to save this without entering a text.")]
    [Required]
    public string RequiredString { get; set; }
    

    Text Length Restriction

    With the MaxLength attribute it is possible to limit the length of the entered text. In this example it's limited to 6 characters.

    [DisplayName("Limited Text Length")]
    [Description("With the MaxLength attribute it is possible to limit the length of the entered text. In this case it's limited to 6 characters.")]
    [MaxLength(6)]
    public string LimitedString { get; set; }
    

    Number Input

    Min and Max Constraints

    Minimum and Maximum values can be defined by applying the MinValue and MaxValue attributes;

    [DisplayName("Min and Max Constraints")]
    [Description("This integer property accepts values from 1 to 10 only.")]
    [MinValue(1), MaxValue(10)]
    public int MinMaxValue { get; set; } = 1;
    
    SDK
    On this Page
    Back to Top Copyright 2022 © EMBY LLC. Please see our terms of use and privacy policy.