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

Add email form validation #199

Closed
wants to merge 1 commit into from
Closed

Add email form validation #199

wants to merge 1 commit into from

Conversation

jatindersingh93
Copy link
Contributor

@jatindersingh93 jatindersingh93 commented May 17, 2024

  • Add Email validation to the invite link
  • Validate using Regex
  • Notify if email syntax is not correct
  • currently not using required, we may deal in a separate ticket as it may require conditional schema

SC3599

Description

Types of changes

Checklist

  • I have read the CONTRIBUTING doc
  • I have checked that unit tests pass locally with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Further comments

Copy link

Coverage Report (Application)

Totals Coverage
Statements: 70.67% ( 53 / 75 )
Methods: 62.5% ( 5 / 8 )
Lines: 81.63% ( 40 / 49 )
Branches: 44.44% ( 8 / 18 )

Copy link

github-actions bot commented May 17, 2024

Coverage Report (Frontend)

Totals Coverage
Statements: 19.42% ( 706 / 3636 )
Methods: 18.64% ( 134 / 719 )
Lines: 23.28% ( 491 / 2109 )
Branches: 10.02% ( 81 / 808 )

Copy link

codeclimate bot commented May 17, 2024

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.

@jatindersingh93 jatindersingh93 marked this pull request as ready for review May 18, 2024 00:12
//Validation
const schema = object({
Email: string().matches(new RegExp(Regex.EMAIL), 'Provide a valid email address')
});
Copy link
Contributor

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.

Copy link
Contributor

@TimCsaky TimCsaky May 22, 2024

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';
Copy link
Contributor

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">
Copy link
Contributor

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"
Copy link
Contributor

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')
});
Copy link
Contributor

@TimCsaky TimCsaky May 22, 2024

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

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.

2 participants