Skip to content

Commit

Permalink
chore: Validate type
Browse files Browse the repository at this point in the history
  • Loading branch information
dougfabris committed Dec 24, 2024
1 parent ae789d3 commit ff50cfa
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { action } from '@storybook/addon-actions';
import { countries } from 'countries-list';
import type { Validate } from 'react-hook-form';

export const logSubmit =
<T extends (...args: any[]) => any>(onSubmit: T) =>
Expand Down Expand Up @@ -40,7 +39,7 @@ export const validateEmail = fetchMock('/email/validate', (email: string) => {
return true;
});

export const validatePassword: Validate<string> = (password: string) => {
export const validatePassword = (password: string) => {
if (password.length < 6) {
return `Password is too short`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ type AdminInfoFormProps = {
passwordRulesHint: string;
keepPosted?: boolean;
initialValues?: Omit<AdminInfoPayload, 'password'>;
validateUsername: Validate<string>;
validateEmail: Validate<string>;
validatePassword: Validate<string>;
validateUsername: Validate<string, AdminInfoPayload>;
validateEmail: Validate<string, AdminInfoPayload>;
validatePassword: Validate<string, AdminInfoPayload>;
onSubmit: SubmitHandler<AdminInfoPayload>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ type CreateCloudWorkspaceFormProps = {
languageOptions: SelectOption[];
domain: string;
onBackButtonClick?: () => void;
validateUrl: Validate<string>;
validateEmail: Validate<string>;
validateUrl: Validate<string, CreateCloudWorkspaceFormPayload>;
validateEmail: Validate<string, CreateCloudWorkspaceFormPayload>;
};

const CreateCloudWorkspaceForm = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ type CreateFirstMemberFormProps = {
organizationName: string;
onSubmit: SubmitHandler<CreateFirstMemberFormPayload>;
onBackButtonClick: () => void;
validateUsername: Validate<string>;
validatePassword: Validate<string>;
validateUsername: Validate<string, CreateFirstMemberFormPayload>;
validatePassword: Validate<string, CreateFirstMemberFormPayload>;
};

const CreateFirstMemberForm = ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export type CreateNewPasswordPayload = {

type CreateNewPasswordProps = {
initialValues?: CreateNewPasswordPayload;
validatePassword: Validate<string>;
validatePasswordConfirmation: Validate<string>;
validatePassword: Validate<string, CreateNewPasswordPayload>;
validatePasswordConfirmation: Validate<string, CreateNewPasswordPayload>;
onSubmit: SubmitHandler<CreateNewPasswordPayload>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ export type NewAccountPayload = {

type NewAccountFormProps = {
initialValues?: Omit<NewAccountPayload, 'password'>;
validateEmail: Validate<string>;
validatePassword: Validate<string>;
validateConfirmationPassword: Validate<string>;
validateEmail: Validate<string, NewAccountPayload>;
validatePassword: Validate<string, NewAccountPayload>;
validateConfirmationPassword: Validate<string, NewAccountPayload>;
onSubmit: SubmitHandler<NewAccountPayload>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ type RegisterServerFormProps = {
currentStep: number;
stepCount: number;
initialValues?: Partial<RegisterServerPayload>;
validateEmail?: Validate<string>;
validateEmail?: Validate<string, RegisterServerPayload>;
onSubmit: SubmitHandler<RegisterServerPayload>;
onClickRegisterOffline: () => void;
termsHref?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ type RequestTrialFormProps = {
countryOptions: SelectOption[];
onSubmit: SubmitHandler<RequestTrialPayload>;
onManageWorkspaceClick: () => void;
validateEmail: Validate<string>;
validateEmail: Validate<string, RequestTrialPayload>;
termsHref?: string;
policyHref?: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export type ResetPasswordFormPayload = {

type ResetPasswordFormProps = {
initialValues?: ResetPasswordFormPayload;
validateEmail: Validate<string>;
validateEmail: Validate<string, ResetPasswordFormPayload>;
onSubmit: SubmitHandler<ResetPasswordFormPayload>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ type AdminInfoPageProps = {
passwordRulesHint: string;
keepPosted?: boolean;
initialValues?: Omit<AdminInfoPayload, 'password'>;
validateUsername: Validate<string>;
validateEmail: Validate<string>;
validatePassword: Validate<string>;
validateUsername: Validate<string, AdminInfoPayload>;
validateEmail: Validate<string, AdminInfoPayload>;
validatePassword: Validate<string, AdminInfoPayload>;
onSubmit: SubmitHandler<AdminInfoPayload>;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import type { NewAccountPayload } from '../../forms/NewAccountForm/NewAccountFor

type CreateNewAccountPageProps = {
initialValues?: Omit<NewAccountPayload, 'password'>;
validateEmail: Validate<string>;
validatePassword: Validate<string>;
validateConfirmationPassword: Validate<string>;
validateEmail: Validate<string, NewAccountPayload>;
validatePassword: Validate<string, NewAccountPayload>;
validateConfirmationPassword: Validate<string, NewAccountPayload>;
onSubmit: SubmitHandler<NewAccountPayload>;
onLogin: () => void;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import type { CreateNewPasswordPayload } from '../../forms/CreateNewPassword/Cre

type CreateNewPasswordPageProps = {
initialValues?: CreateNewPasswordPayload;
validatePassword: Validate<string>;
validatePasswordConfirmation: Validate<string>;
validatePassword: Validate<string, CreateNewPasswordPayload>;
validatePasswordConfirmation: Validate<string, CreateNewPasswordPayload>;
onSubmit: SubmitHandler<CreateNewPasswordPayload>;
onLogin: () => void;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type RegisterServerPageProps = {
onSubmit: SubmitHandler<RegisterServerPayload>;
onClickRegisterOffline: () => void;
offline?: boolean;
validateEmail?: Validate<string>;
validateEmail?: Validate<string, RegisterServerPayload>;
termsHref?: string;
policyHref?: string;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import type { ResetPasswordFormPayload } from '../../forms/ResetPasswordForm/Res

type ResetPasswordPageProps = {
initialValues?: ResetPasswordFormPayload;
validateEmail: Validate<string>;
validateEmail: Validate<string, ResetPasswordFormPayload>;
onSubmit: SubmitHandler<ResetPasswordFormPayload>;
onLogin: () => void;
};
Expand Down

0 comments on commit ff50cfa

Please sign in to comment.