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

Added support for more complex expressions to Validator.Value #1385

Merged
merged 11 commits into from Jun 4, 2022

Conversation

acizmarik
Copy link
Member

This PR adds support for complex expressions to Validator.Value. I am not even sure, whether this is a new feature or a fix.

In BusinessPack, controls automatically set their Validator.Value according to the passed value binding (e.g. DatePicker's SelectedDate="{value: MyDateProperty}" generates knockout binding dotvvm-validation with value MyDateProperty). However, this breaks once user tries to specify something more complex, for example MyDateProperty.ToBrowserLocalTime().ToString("yyyy").

Therefore, this PR implements an unwrapping mechanism that tries to unwrap bindings so that errors can be propagated to the correct observable.

@acizmarik
Copy link
Member Author

There is one more place where I need to fix this. ISortingOptions.SortExpression can be populated with DateTimeProperty.ToBrowserLocalTime() when user tries to sort by specifying AllowSorting="true" and clicking on the column within a grid.

image

However, it is going to be separate PR as it is handled a bit differently there

@acizmarik acizmarik force-pushed the feature/validator-complex-expressions-reductions branch from 4aafa39 to bb05eb5 Compare June 4, 2022 11:43
src/Framework/Framework/Controls/KnockoutHelper.cs Outdated Show resolved Hide resolved
Co-authored-by: Stanislav Lukeš <exyi@outlook.cz>
@acizmarik acizmarik merged commit f82c7ac into main Jun 4, 2022
@acizmarik acizmarik deleted the feature/validator-complex-expressions-reductions branch June 4, 2022 12:36
@acizmarik acizmarik mentioned this pull request Jul 27, 2022
@exyi exyi added this to the Version 4.1 milestone Aug 31, 2022
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

Successfully merging this pull request may close these issues.

None yet

2 participants