Skip to content
This repository was archived by the owner on Nov 7, 2018. It is now read-only.
This repository was archived by the owner on Nov 7, 2018. It is now read-only.

Add built in support for validating options #227

Closed
@Alxandr

Description

@Alxandr

I just made an Option class that takes strings that are required to be a certain format. I would like the configuration to fail after hydration if the values provided are invalid. A good example is if you need an email (ignoring how hard it can be to validate emails).

Today I can solve this by creating an IPostConfigureOptions that resolves to a ValidateOptions class that checks if the options in question implement an IValidatable interface, and if so calls Validate().

It would, however, be preferable if I knew that validation always ran last (after all post configure handlers - if any). Therefore I suggest adding first class support for IValidateOptions which runs after runs after IPostConfigureOptions. This interface would behave the exact same as IPostConfigureOptions, except it would be guaranteed to run after all IPostConfigureOptions.

It can also be discussed whether or not default implementation that does something similar to my described ValidateOptions class would be useful.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions