-
Notifications
You must be signed in to change notification settings - Fork 9
[RMBWEB-2780] Support for structured validation results #87
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
Changes from 1 commit
83cd99a
8d68591
f466115
db9f109
227f425
d84c44a
90e4499
78f35e5
b2f88ba
e5afe2a
3e45f64
511d66f
b8fb666
9065ddf
5d56725
2c76ca8
a8cb353
031f8a1
ba4b45e
dbba8f5
a5ec69d
82e505b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ export function normalizeRawError(err: ValidationResult): ValidationRawError { | |
| } | ||
|
|
||
| if (err === false || err === '' || err === null) { | ||
| // TODO: print an alert? | ||
| return undefined | ||
| } | ||
|
|
||
|
|
@@ -18,11 +17,27 @@ export function normalizeError(rawError: ValidationRawError): ValidationError { | |
| if (isErrorObject(rawError)) { | ||
| return rawError.message | ||
| } | ||
| return rawError | ||
|
|
||
| return convertEmptyStringWithWarning(rawError) | ||
| } | ||
|
|
||
| export function isErrorObject(err: any): err is ValidationErrorObject { | ||
| return err != null && typeof err === 'object' && 'message' in err | ||
| if (err != null && typeof err === 'object' && 'message' in err) { | ||
|
||
| if (!err.message) { | ||
| console.log(err) | ||
| throw new Error('ValidationErrorObject message property cannot be empty') | ||
|
||
| } | ||
| return true | ||
| } | ||
| return false | ||
|
Comment on lines
+24
to
+26
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NIP: 特地改成这样有啥说法么 = = There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 没懂.. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 一开始 pr 里是 后面有比前面更好吗… There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 你不说我都忘记之前的 isErrorObject 的实现是 return a && b && c 了。。 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 如果是: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 一开始我也是这么想的 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 我试了下, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 对喔,那就更没问题了 |
||
| } | ||
|
|
||
| export function convertEmptyStringWithWarning<T>(err: T) { | ||
| if (typeof err === 'string' && err === '') { | ||
| console.warn('An empty string errs should be replaced with undefined.') | ||
| return undefined | ||
| } | ||
| return err | ||
| } | ||
|
|
||
| export function isPromiseLike(arg: any): arg is Promise<any> { | ||
|
|
||
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.
需要
normalizeError({ message: '' })的 case