ResourceManagement icon indicating copy to clipboard operation
ResourceManagement copied to clipboard

Need validation on Domain objects

Open csharpfritz opened this issue 6 years ago • 6 comments

We need to add validation to the objects in Fritz.ResourceManagement.Domain similar to the implementation of ScheduleItem

csharpfritz avatar Jun 16 '19 15:06 csharpfritz

Hi you can assign me this issue

marblekirby avatar Jul 13 '19 12:07 marblekirby

Do we have a list of validation rules anywhere? Such as names (GivenName, SurName) have a min length, phone numbers should be valid for a certain country? Thanks

marblekirby avatar Jul 13 '19 15:07 marblekirby

Some initial rules that we can apply during create and edit operations.

  • Person

    • GivenName and Surname should be required
    • At least one PersonType should be defined
    • Phone number is required
  • ScheduleItem

    • Required fields: Status, Name, StartDateTime, EndDateTime
    • Name max length: 50 characters
    • Minimum duration: 10 minutes
  • ScheduleException

    • Required fields: StartDate, EndDate, Name
    • StartDate must be before EndDate
    • Minimum duration of 1 day
  • RecurringSchedule

    • Required fields: Name, CronPattern, Duration, MinStartDateTime, MaxEndDateTime
    • MinStartDateTime must be before MaxEndDateTime
    • Minimum duration of 30 minutes
    • CronPattern must be a valid CRON pattern

csharpfritz avatar Jul 17 '19 15:07 csharpfritz

If it helps, there is a great library for this sort of validation code I can recommend: https://fluentvalidation.net/ It is net standard code so should work with the tech here, and has a nice API with the advantage of being able to create validation helper e.g email is valid, independent of applying them to multiple business objectives e.g the customer has a valid email address, the staff member has a valid email address. This might help keep things more granular and SRP so more people can collaborate on what looks to be a complex issue at various tech levels.

SimonGeering avatar Jul 17 '19 21:07 SimonGeering

Hi, I am familar with Fluent Validation and used it alot quite recently. I think creating validators for the domain objects would be a better approach, although I was going with the current style of validation that was used in the ScheduleItem. I think implementing Fluent Validation is a good shout.

marblekirby avatar Jul 17 '19 22:07 marblekirby

It dawned on me that we probably need to restrict which characters are allowed to be entered in certain fields - for the time being anyway. For example, I doubt that we would legitimately permit emojis in the majority, if not all, identity fields.

hugodahl avatar Jul 18 '19 14:07 hugodahl