Repository navigation
FormHelper 6.0 - #44
Merged
Merged
Conversation
- Target .NET Core 3.1 and .NET 5 to 10; no package dependencies (Newtonsoft.Json, Razor runtime compilation and embedded file provider removed) - FormResult is an IActionResult that writes its own camelCase JSON; validation errors carry a list of messages; CreateValidationErrorResult - [FormValidator] works on Razor Pages, runs IFormModelValidator (async), skips GET requests, returns a FormResult for an invalid antiforgery token - Redirect results (RedirectToAction, RedirectToPage...) become a FormResult redirect, keeping TempData; method-preserving redirects are left as they are - An invalid token rejected before [FormValidator] (Razor Pages, [AutoValidateAntiforgeryToken]) also returns FormHelper's message - <formhelper-scripts /> and <formhelper-styles /> with versioned urls - New options: InvalidRequestMessage, ErrorMessage, ClientValidation, InputErrorCssClass, MessageErrorCssClass, LocalizationResourceType, JsonSerializerOptions - Forms get data-formhelper / data-fh-* attributes - Removed: EmbeddedFiles option, FormConfig.FormTitle, the dist folder
- Plain JavaScript in client/src, built with esbuild into src/FormHelper/Scripts and src/FormHelper/Styles (npm run build / check) - Works with or without jQuery: jQuery Validation Unobtrusive when it is on the page, otherwise a built-in validator reading the same data-val-* rules, including [Remote] and custom rules (FormHelper.validation.addRule) - formhelper.bundle.js includes jQuery Validation 1.22.1 and Unobtrusive 4.0.0, skipped when the page already has them; jQuery 3 and 4 - Server messages are shown as text ([Remote] responses too) - JavaScript API (submit, validate, reset, fill, showErrors, configure), DOM events and beforeSubmit(form, request) / callback(result, form) - fhToastr without jQuery; messages escaped by default - Removed: $.fn.fillFormFields, $.fn.fhReset, fhToastr.information
A replacement for the deprecated FluentValidation.AspNetCore integration, for FluentValidation 11 and 12: - AddFormHelperFluentValidation() validates the models of [FormValidator] actions and Razor Pages asynchronously (MustAsync works) - Client-side attributes for NotNull, NotEmpty, Length, MinimumLength, MaximumLength, Matches, EmailAddress, CreditCard, InclusiveBetween, GreaterThanOrEqualTo / LessThanOrEqualTo a constant and Equal to another property; rules with conditions or that the browser can't run the same way (e.g. regex with RegexOptions, \w \d \b, .NET-only syntax) stay on the server - Steps aside when FluentValidation.AspNetCore's auto validation or client adapters are registered, so nothing is validated twice
- FormHelper.Tests and FormHelper.FluentValidation.Tests (xUnit) on .NET Core 3.1, .NET 6, 8 and 10; FluentValidation 11 and 12, and the real FluentValidation.AspNetCore package on the older runtimes - Browser tests of the client script against the sample in headless Chrome (cd client && npm test), with and without jQuery
.NET 10 and Bootstrap 5; pages with jQuery (tag helper, html helper), without jQuery (JSON data type), Razor Pages, normal posts and a form loaded into a modal. Uses FormHelper.FluentValidation.
- README rewritten for 6.0, MIGRATION.md with a prompt for AI assistants - CI: .NET tests on .NET Core 3.1 (Windows), 6, 8 and 10, client build check, browser tests and packages - Release workflow attaching the scripts and styles to GitHub releases
The Title field also has a [Remote] rule. On a slower machine (CI) the server didn't answer within the fixed wait, so the rule under test hadn't run yet.
- Exclude the built scripts/styles and the vendored jQuery Validation files from the analysis (.sonarcloud.properties) - CI installs npm packages without lifecycle scripts - Tests get free ports from the OS instead of random numbers - Subresource integrity for the sample's CDN files - Timeouts for the FluentValidation adapter's regular expressions
|
This was referenced Sep 24, 2026
Closed
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



FormHelper 6.0 is a major release. The upgrade steps are in MIGRATION.md, which also has a prompt for AI assistants.
What's new
formhelper.jsis plain JavaScript. It uses jQuery Validation Unobtrusive when the page has it, otherwise a built-in validator that reads the samedata-val-*attributes (including[Remote]).formhelper.bundle.jsincludes jQuery Validation and Unobtrusive for jQuery projects (jQuery 3 and 4).[FormValidator]on the PageModel.[FormValidator]actions and pages asynchronously (MustAsyncworks) and adds client-side rules. Works with FluentValidation 11 and 12.FormResultis anIActionResultwith its own camelCase JSON. It is independent of the application's JSON settings.RedirectToAction,RedirectToPage,RedirectandLocalRedirectwork from FormHelper posts. TempData is kept.ErrorMessage,InvalidRequestMessage), localization, CSS classes for Bootstrap/Tailwind, client validation engine.FormHelper.submit/validate/reset/fill/showErrors/configure), DOM events, custom validation rules.<formhelper-scripts />and<formhelper-styles />tag helpers with versioned urls.[Remote]responses) are always shown as text.Breaking changes
See MIGRATION.md. In short:
Create...Resultmethods returnFormResultinstead ofJsonResult.validationErrors[i].messageis nowmessages(an array).beforeSubmitgets(form, request).fillFormFields/fhResetare replaced byFormHelper.fill/FormHelper.reset.EmbeddedFilesoption and thedistfolder were removed.Tests
cd client && npm test), with and without jQuery.Closes #12, closes #22, closes #25, closes #35, closes #37, closes #38, closes #41.