-
Notifications
You must be signed in to change notification settings - Fork 69
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
Introduce PropertyFormat to avoid validation errors that can lead to internal exceptions #248
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main thing is that you have forgotten the server side validation and I am not so happy with client side validation yet. See comments for more infos. Continue with the good work :)
@@ -42,7 +42,6 @@ public sealed partial class SmtpIntegration : IIntegration | |||
|
|||
public static readonly IntegrationProperty FromEmailProperty = new IntegrationProperty("fromEmail", PropertyType.Text) | |||
{ | |||
Pattern = Patterns.Email, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you put this property at the end, just like in the other property?. My brain is annoying sometimes ;)
if (property.format && property.format !== "None") { | ||
const format = FORMAT_REGEXPS.get(property.format); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove double line.
|
||
|
||
if (format) { | ||
propertyType = propertyType.matches(format, texts.validation.formatFn); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup already provides validation method for email and url. Just use that. There is also emailI18n and perhaps url18n for localized methods in the code base.
@@ -441,6 +441,7 @@ export const EN = { | |||
minItemsFn: (p: { label?: string; min: number }) => `${p.label} must have at least ${p.min || 0} items.`, | |||
minLengthFn: (p: { label?: string; min: number }) => `${p.label} must have at least ${p.min} characters.`, | |||
moreThanFn: (p: { label?: string; more: number }) => `${p.label} must be greater than ${p.more || 0}.`, | |||
formatFn: (p: { label?: string }) => `${p.label} is not in a valid format for this type of field.`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have introduced the format property to provide better validation messages. Otherwise we could just use "pattern", which has a very generic method.
@@ -39,6 +39,8 @@ public sealed record IntegrationProperty(string Name, PropertyType Type) | |||
|
|||
public string? Pattern { get; init; } | |||
|
|||
public PropertyFormat Format { get; init; } = PropertyFormat.None; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validation is missing in the TryGetString method.
Fixes #247 , more info there.
Can you please review my code for now so that I can make some appropriate changes?
Cheers