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

Update for validation unit test coverage #144

Merged
merged 4 commits into from
Oct 6, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 0 additions & 63 deletions src/validators/azureValidator.ts

This file was deleted.

49 changes: 0 additions & 49 deletions src/validators/debounceValidation/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/validators/validationFunctions/hasLowerCase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { IRule } from "../rule";

export class HasLowerCase implements IRule {
public validate(value: string): string | null {
const hasLowerCase = value.search("/(?=.*[a-z]).*/g") !== -1;
const hasLowerCase = value.search(".*[a-z]+.*") !== -1;
return hasLowerCase
? null
: "Password should have at least one lowercase letter from a to z.";
Expand Down
46 changes: 0 additions & 46 deletions src/validators/validationFunctions/isAvailable.ts

This file was deleted.

21 changes: 0 additions & 21 deletions src/validators/validator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { IRule } from "./rule";
import { HasLowerCase } from "./validationFunctions/hasLowerCase";
import { HasNoForbiddenChar } from "./validationFunctions/hasNoForbiddenChar";
import { HasSpecialChar } from "./validationFunctions/hasSpecialChar";
import { IsAvailable } from "./validationFunctions/isAvailable";
import { IsNotEmpty } from "./validationFunctions/isNotEmpty";
import { LengthRange } from "./validationFunctions/lengthRange";

Expand Down Expand Up @@ -56,30 +55,10 @@ export class Validator {
return this;
}

public async isAvailable(
checkAvailable: (
name: string
) => Promise<
| { message: string | null; nameAvailable: boolean; reason: string }
| boolean
>,
errorMessage: string
): Promise<Validator> {
await this.validate(new IsAvailable(checkAvailable, errorMessage));
return this;
}

private validateSync(fn: IRule): void {
const error = fn.validate(this.value) as string | null;
if (error) {
this.errors.add(error);
}
}

private async validate(fn: IRule): Promise<void> {
const error = await fn.validate(this.value);
if (error) {
this.errors.add(error);
}
}
}
Loading