-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add email form validation #199
Conversation
Code Climate has analyzed commit 50c5a8f and detected 0 issues on this pull request. The test coverage on the diff in this pull request is 50.0% (50% is the threshold). This pull request will bring the total coverage in the repository to 24.6% (0.0% change). View more on Code Climate. |
//Validation | ||
const schema = object({ | ||
Email: string().matches(new RegExp(Regex.EMAIL), 'Provide a valid email address') | ||
}); |
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 should do: 'if restrict toggle is on, email field is required' rule
we have an example of how to implement this in previous code.
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.
it will be something like this:
const schema = object({
isRestricted: boolean(),
Email: string().when("isRestricted", {
is: true,
then: string().matches(new RegExp(Regex.EMAIL), 'Provide a valid email address'),
}),
});
i think you'll need to add name=isRestricted
to the isRestricted form component
import { Permissions } from '@/utils/constants'; | ||
import { inviteService } from '@/services'; | ||
import { useAuthStore, useConfigStore, useObjectStore, usePermissionStore, useBucketStore } from '@/store'; | ||
|
||
import type { Ref } from 'vue'; | ||
import type { COMSObject, Bucket } from '@/types'; | ||
import { Regex } from '@/utils/constants'; |
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 Regex
member can be imported in line 11
icon="fa fa-envelope" | ||
class="mr-2" | ||
<p class="mt-4 mb-2">Restrict to user's email</p> | ||
<div class="flex flex-wrap gap-5 mb-3"> |
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.
when you rebase you'll see the structure of this template has changed a bit
<TextInput | ||
v-if="isRestricted" | ||
v-model="formData.email" | ||
name="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.
i see you changed this. either Email or inviteEmail is fine by me
//Validation | ||
const schema = object({ | ||
Email: string().matches(new RegExp(Regex.EMAIL), 'Provide a valid email address') | ||
}); |
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.
it will be something like this:
const schema = object({
isRestricted: boolean(),
Email: string().when("isRestricted", {
is: true,
then: string().matches(new RegExp(Regex.EMAIL), 'Provide a valid email address'),
}),
});
i think you'll need to add name=isRestricted
to the isRestricted form component
SC3599
Description
Types of changes
Checklist
Further comments