{"id":13710486,"url":"https://github.com/james-russo/XamarinForms-UnobtrusiveValidationPlugin","last_synced_at":"2025-05-06T19:31:08.185Z","repository":{"id":95714732,"uuid":"103584966","full_name":"james-russo/XamarinForms-UnobtrusiveValidationPlugin","owner":"james-russo","description":"A plugin library that extends the functionality of FluentValidation for Xamarin.","archived":false,"fork":false,"pushed_at":"2019-08-30T19:47:12.000Z","size":8771,"stargazers_count":27,"open_issues_count":3,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-08T22:05:33.078Z","etag":null,"topics":["fluentvalidation","unobtrusive","validation","xamarin"],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/james-russo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-09-14T21:47:22.000Z","updated_at":"2024-08-01T12:24:45.000Z","dependencies_parsed_at":"2023-04-17T10:02:49.582Z","dependency_job_id":null,"html_url":"https://github.com/james-russo/XamarinForms-UnobtrusiveValidationPlugin","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-russo%2FXamarinForms-UnobtrusiveValidationPlugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-russo%2FXamarinForms-UnobtrusiveValidationPlugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-russo%2FXamarinForms-UnobtrusiveValidationPlugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/james-russo%2FXamarinForms-UnobtrusiveValidationPlugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/james-russo","download_url":"https://codeload.github.com/james-russo/XamarinForms-UnobtrusiveValidationPlugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252753267,"owners_count":21798940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fluentvalidation","unobtrusive","validation","xamarin"],"created_at":"2024-08-02T23:00:57.210Z","updated_at":"2025-05-06T19:31:03.175Z","avatar_url":"https://github.com/james-russo.png","language":"C#","funding_links":[],"categories":["Plugins"],"sub_categories":[],"readme":"# Xamarin.Forms Unobtrusive FluentValidation Plugin\nA plugin library that integrates the functionality of FluentValidation and Xamarin.Forms to provide an unobtrusive user experience.\n\n\nThe library follows an MVVM pattern and below are examples on how to get started.  \n \n ## Preview\n ![alt text](https://github.com/james-russo/XamarinForms-UnobtrusiveValidationPlugin/blob/master/samples/sample.gif \"Sample In Action\")\n\n \n ### Get Started\n \n #### FluentValidation AbstractValidator (EnhancedAbstractValidator)\n \n When using FluentValidation library, normally you would derive from *AbstractValidator\u003cT\u003e*, however in this library you need to use **EnhancedAbstractValidator\u003cT\u003e**.  \n This class extends AbstractValidator\u003cT\u003e on and provides a new method **RuleForProp**.  This method is essential in order for your view model later to work with the validator.\n \n ```csharp\n \n public class PersonValidator : EnhancedAbstractValidator\u003cPersonViewModel\u003e\n {\n\tpublic PersonValidator()\n\t{\n\t\tRuleForProp(a =\u003e a.FirstName)\n\t\t\t.NotNull();\n\t} \n }\n \n ```\n \n ### ViewModel (AbstractValidationViewModel)\n \n When deriving from AbstractValidationViewModel, you will want to the class **ValidatableProperty\u003c\u003e**.  This property encapsulates the needed propertys for the UI to bind to accordingly.\n \n ```csharp\n \n [FluentValidation.Attributes.Validator(typeof(PersonValidator))]\n public class PersonViewModel : AbstractValidationViewModel\n {\n\tpublic ValidatableProperty\u003cstring\u003e FirstName { get; set; } = new ValidatableProperty\u003cstring\u003e();\n }\n \n ```\n \n ### Xamarin.Forms UI Page\n \n #### Code Page\n ```csharp\n    public class PersonPage : ContentPage\n    {\n        public PersonPage()\n        {\n            BindingContext = new PersonViewModel();\n\n\t\t\t//Here we pass in the name of the property we would like this control to bind to. \n            var firstNameControl = new ValidatableEntryControl(nameof(PersonViewModel.FirstName));\n\n            var sl = new StackLayout()\n            {\n                Orientation = StackOrientation.Vertical\n            };\n\n            sl.Children.Add(firstNameControl);\n\t\t\t\n            var submitButton = new Button()\n\t\t\t{\n\t\t\t\tText = \"Submit\"\n\t\t\t};\n\n\t\t\t//Sample to trigger validator, normally you would call the validator from within your view model.\n            submitButton.SetBinding(Button.CommandProperty, nameof(PersonViewModel.ValidateCommand));\n\n            sl.Children.Add(submitButton);\n\n            this.Content = sl;\n        }\n\n    }\n \n ```\n #### XAML Page\n ```xml\n\u003c?xml version=\"1.0\" encoding=\"UTF-8\"?\u003e\n\u003cContentPage xmlns=\"http://xamarin.com/schemas/2014/forms\" \n    xmlns:x=\"http://schemas.microsoft.com/winfx/2009/xaml\" \n    x:Class=\"Test.XamlTest\"\n    xmlns:custom=\"clr-namespace:Xamarin.Plugins.UnobtrusiveFluentValidation;assembly=Xamarin.Plugins.FluentValidation\"\u003e\n\t\u003cContentPage.Content\u003e\n        \u003cStackLayout Orientation=\"Vertical\"\u003e\n            \u003cLabel\u003eName\u003c/Label\u003e\n            \u003ccustom:ValidatableEntryControl BindingName=\"Name\"\u003e\u003c/custom:ValidatableEntryControl\u003e\n            \u003cButton x:Name=\"btnSubmit\" Text=\"Submit\" Command=\"{Binding ValidateCommand}\"\u003e\u003c/Button\u003e\n        \u003c/StackLayout\u003e\n\t\u003c/ContentPage.Content\u003e\n\u003c/ContentPage\u003e\t\n\n ```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames-russo%2FXamarinForms-UnobtrusiveValidationPlugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjames-russo%2FXamarinForms-UnobtrusiveValidationPlugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjames-russo%2FXamarinForms-UnobtrusiveValidationPlugin/lists"}