Open Closed

ABP Suite Server validation errors : entity properties still required when they shouldn't be #275


User avatar
0
pkouame created

Check the docs before asking a question: https://docs.abp.io/en/commercial/latest/
Check the samples, to see the basic tasks: https://docs.abp.io/en/commercial/latest/samples/index
The exact solution to your question may have been answered before, please use the search on the homepage.

  • ABP Framework version: v2.9.0

  • UI type: Angular / MVC

  • Tiered (MVC) or Identity Server Seperated (Angular): yes

  • Exception message and stack trace:

  • Steps to reproduce the issue:

in abp suite 2.9.0 - create a new entity with non-required properties (string type usually in my case)
migrate and update
form doesn't validate when non-required field is skipped

see below. In my Vendor Entity the Phone property is tagged as non-required:

Screen Shot 2020-06-29 at 11.47.53 AM.png

server requires validation :

Screen Shot 2020-06-29 at 11.47.53 AM.png

Even though the create DTO seems correct :

using System;
using System.ComponentModel.DataAnnotations;

namespace Skipj.Track.Vendors
{
    public class VendorCreateDto
    {

        [Required]
        [StringLength(VendorConsts.NameMaxLength, MinimumLength = VendorConsts.NameMinLength)]
        public string Name { get; set; }

        [StringLength(VendorConsts.PhoneMaxLength, MinimumLength = VendorConsts.PhoneMinLength)]
        public string Phone { get; set; }

        [EmailAddress]
        [StringLength(VendorConsts.EmailMaxLength, MinimumLength = VendorConsts.EmailMinLength)]
        public string Email { get; set; }

        [StringLength(VendorConsts.WebsiteMaxLength, MinimumLength = VendorConsts.WebsiteMinLength)]
        public string Website { get; set; }

        [StringLength(VendorConsts.TaxIdMaxLength, MinimumLength = VendorConsts.TaxIdMinLength)]
        public string TaxId { get; set; }

        [StringLength(VendorConsts.VendorIdMaxLength, MinimumLength = VendorConsts.VendorIdMinLength)]
        public string VendorId { get; set; }

        [StringLength(VendorConsts.AltNameMaxLength, MinimumLength = VendorConsts.AltNameMinLength)]
        public string AltName { get; set; }

        [StringLength(VendorConsts.DbaNameMaxLength, MinimumLength = VendorConsts.DbaNameMinLength)]
        public string DbaName { get; set; }

        [StringLength(VendorConsts.NotesMaxLength, MinimumLength = VendorConsts.NotesMinLength)]
        public string Notes { get; set; }

        [Required]
        public bool IsPrime { get; set; }

        [Required]
        public bool IsMdBased { get; set; }

        public bool IsWomanOwned { get; set; }

        [StringLength(VendorConsts.RatingMaxLength, MinimumLength = VendorConsts.RatingMinLength)]
        public string Rating { get; set; }

        [StringLength(VendorConsts.DisplayNameMaxLength, MinimumLength = VendorConsts.DisplayNameMinLength)]
        public string DisplayName { get; set; }

        public bool HasMdEmployees { get; set; }

        [StringLength(VendorConsts.DunsNumberMaxLength, MinimumLength = VendorConsts.DunsNumberMinLength)]
        public string DunsNumber { get; set; }

    }
}

the angular input form doesn't mark anything as required either :

    
        
            

**SECOND question while I'm at it : why aren't required fields tagged as such on the angular form (like red dot or asterisk on the MV forms)
**


2 Answer(s)
  • User Avatar
    0
    pkouame created

    Any news on this case?

  • User Avatar
    0
    alper created
    Support Team Director

    this is expected behaviour.
    the phone field is not marked as required but you set min max length.
    so user can leave this field empty, but if any value is entered, it must be with min 1, max 50 characters.

Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
Do you need assistance from an ABP expert?
Schedule a Meeting
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v9.2.0-preview. Updated on March 13, 2025, 04:08