Skip to content
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

take feedback comment #1

Conversation

kotarella1110
Copy link

take comments react-hook-form#32

src/yup.ts Outdated
previous[path].types &&
previous[path].types[type]
? [
...[].concat(previous[path].types[type]),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we just use spread operator here?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous[path].types[type] type is string | string[].
I think [].concat(previous[path].types[type]) is better than typeof previous[path].types[type] === 'string' ? [previous[path].types[type]] : previous[path].types[type] 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i thought [...previous[path].types[type]] is the same as ...[].concat(previous[path].types[type])?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose this instead [...(previous[path].types[type] || []), message] to stay consistent with your code.

Copy link
Author

@kotarella1110 kotarella1110 Jul 21, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bluebill1049 @Vandell63 umm... The code doesn't support when previous[path].types[type] is a string.
I think it's correct to use concat.

スクリーンショット 2020-07-21 17 23 14

const string1 = 'foo';
const string2 = 'bar';
// string
const test1 = [...string1, string2]; // ['f', 'o', 'o', 'bar']
const test2 = [...[].concat(string1), string2]; // ['foo', 'bar']
// string[]
const test3 = [...test2, string1]; // ['foo', 'bar', 'foo']
const test4 = [...[].concat(test2), string2]; // ['foo', 'bar', 'foo']

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i see that's fine by me 👍

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explanation.

Copy link

@bluebill1049 bluebill1049 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/yup.test.ts Outdated
`);
expect(resolve.errors.age.types).toMatchInlineSnapshot(`undefined`);
expect(resolve.errors.createdOn.types).toMatchInlineSnapshot(`undefined`);
expect(resolve.errors.password.types).toMatchInlineSnapshot(`undefined`);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just for 3 of them expect(resolve.errors.password.types).toBeUndefined() finally.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will fix this 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/yup.ts Outdated
...(validateAllFieldCriteria
? {
types: {
...((previous[path] && previous[path].types) || {}),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store in variable to avoid redundancy maybe with line 22 and 24. Not mandatory.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not mandatory too to save few bytes as @bluebill tell me before

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

src/yup.ts Outdated
previous[path].types &&
previous[path].types[type]
? [
...[].concat(previous[path].types[type]),
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose this instead [...(previous[path].types[type] || []), message] to stay consistent with your code.

@bluebill1049
Copy link

thanks for the review @Vandell63 please merge it in 👍

@Paul-Vandell Paul-Vandell merged commit d720aa2 into Paul-Vandell:feature/support-multiple-errors-message Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants