enisn / Xamarin.Forms.InputKit

CheckBox, Radio Button, Labeled Slider, Dropdowns etc.
MIT License
589 stars 100 forks source link

material:TextField RequiredValidation validator not working #349

Open wasyster opened 1 year ago

wasyster commented 1 year ago

I have a simple test app, to test the validation:

<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:uranium="http://schemas.enisn-projects.io/dotnet/maui/uraniumui"
             xmlns:material="http://schemas.enisn-projects.io/dotnet/maui/uraniumui/material"
             xmlns:validation="clr-namespace:InputKit.Shared.Validations;assembly=InputKit.Maui"
             xmlns:validationRules="clr-namespace:TastAppForUraniumUI.Validators"
             xmlns:v="clr-namespace:UraniumUI.Validations;assembly=UraniumUI.Validations.DataAnnotations"
             xmlns:input="clr-namespace:InputKit.Shared.Controls;assembly=InputKit.Maui"
             xmlns:fa="clr-namespace:UraniumUI.Icons.FontAwesome;assembly=UraniumUI.Icons.FontAwesome"
             xmlns:materialIcons="clr-namespace:UraniumUI.Icons.MaterialIcons;assembly=UraniumUI.Icons.MaterialIcons"
             xmlns:viewModel="clr-namespace:TastAppForUraniumUI"
             x:DataType="viewModel:MainPageViewModel"
             x:Class="TastAppForUraniumUI.MainPage"
             xmlns:local="clr-namespace:TastAppForUraniumUI">
    <VerticalStackLayout>
        <material:TextField Text="{Binding Name}" Title="Name"
                            Icon="{FontImageSource FontFamily=MaterialRegular, Glyph={x:Static materialIcons:MaterialRegular.Person}}">
            <material:TextField.Validations>
                <validation:RequiredValidation Message="Please fill this field" />
            </material:TextField.Validations>
        </material:TextField>
        <material:TextField Text="{Binding Email}" Title="E-mail"
                            Icon="{FontImageSource FontFamily=MaterialRegular, Glyph={x:Static materialIcons:MaterialRegular.Email}}">
            <validation:RequiredValidation />
            <validation:RegexValidation Pattern="{x:Static input:AdvancedEntry.REGEX_EMAIL}" Message="Invalid email address" />
        </material:TextField>

        <input:FormView>
            <input:AdvancedEntry Title="Type your email below"
                                 IconImage="{FontImageSource FontFamily=MaterialRegular, Glyph={x:Static materialIcons:MaterialRegular.Email}, Color={StaticResource Primary}}">
                <input:AdvancedEntry.Validations>
                    <validation:RequiredValidation />
                    <validation:RegexValidation Pattern="{x:Static input:AdvancedEntry.REGEX_EMAIL}" Message="Invalid email address" />
                </input:AdvancedEntry.Validations>
            </input:AdvancedEntry>
            <Button Text="Submit" input:FormView.IsSubmitButton="True" />
        </input:FormView>
    </VerticalStackLayout>
</ContentPage>

On the AdvancedEntry the required validation is working, but the the TextField it's not. I even tried to write my own not empty validator, and that wasn't working too. When I debug my validator, I saw that on key down (typing new chars) it detected the changes, but when I use backspace no event was triggered.