Skip to content

Correcting and clarifying RegularExpressionAttribute.IsValid #8165

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,18 +199,17 @@ The regular expression searches for an exact match, not using `^` before and `$`
</Parameters>
<Docs>
<param name="value">The data field value to validate.</param>
<summary>Checks whether the value entered by the user matches the regular expression pattern.</summary>
<summary>Converts the value entered by the user to a string using <see cref="M:System.Convert.ToString(System.Object,System.IFormatProvider)" /> with <see cref="P:System.Globalization.CultureInfo.CurrentCulture" /> and matches it with the regular expression pattern. If <paramref name="value"/> is null, or is converted to a null or empty string then it is considered valid.</summary>
<returns>
<see langword="true" /> if validation is successful; otherwise, <see langword="false" />.</returns>
<see langword="true" /> if validation is successful - or if <paramref name="value"/> is null, or is converted to an empty string; otherwise, <see langword="false" />.</returns>
<remarks>
<format type="text/markdown"><![CDATA[
This override performs the specific regular expression matching of `value` field.
]]></format>
</remarks>
<exception cref="T:System.ComponentModel.DataAnnotations.ValidationException">The data field value did not match the regular expression pattern.</exception>
<exception cref="T:System.InvalidOperationException">The current attribute is ill-formed.</exception>
<exception cref="T:System.InvalidOperationException"><see cref="P:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.Pattern" /> is null or empty.</exception>
<exception cref="T:System.ArgumentException">
<see cref="P:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.Pattern" /> is not a valid regular expression.</exception>
<see cref="P:System.ComponentModel.DataAnnotations.RegularExpressionAttribute.Pattern" /> is not a valid regular expression (directly thrown from <see cref="P:System.Text.RegularExpressions.Regex" />'s constructor).</exception>
</Docs>
</Member>
<Member MemberName="MatchTimeout">
Expand Down