Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validating IsValueType using ValidateObjectTree #38

Closed
freenetbrasil opened this issue Mar 29, 2022 · 1 comment
Closed

Validating IsValueType using ValidateObjectTree #38

freenetbrasil opened this issue Mar 29, 2022 · 1 comment

Comments

@freenetbrasil
Copy link

Hi,

I've a struct similar to this:

public string Photo { get; set; }
public string Name { get; set; }
public string Last { get; set; }
public int? InfoInt { get; set; } = null;

On the submit button I've the following code:

void SubmitForm(EditContext editContext)
    {
        editContext.ValidateObjectTree();
    }

When I execute the ValidateObjectTree it doesn't validate the field 'InfoInt' which is 'int?', looking through the source code I found on 'EditContextExtensions.cs' on the 'ValidateProperty' method you check for this:

		if (property.PropertyType.IsValueType)
				return;

This prevent any integer validation, if I comment this out the validation works as planned.

Any special reason for this? Can I safely comment this out? Any help is appreciated.

Thanks

@mrpmorris
Copy link
Owner

Any rules for ValueType properties should be added to the validator of the owning class.

Here is why that check was added.
#28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants