Skip to content

Commit

Permalink
[breaking] use 'null' instead of 'false' to disable invalidClass.
Browse files Browse the repository at this point in the history
  • Loading branch information
RillingDev committed Mar 15, 2021
1 parent 7994be9 commit f5290f2
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Ok.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ type ValidatorMap = Map<string, Validator>;
*/
export class Ok {
readonly #map: ValidatorMap;
readonly #invalidClass: string | false;
readonly #invalidClass: string | null;

/**
* Ok constructor.
*
* @public
* @param validators Object containing the validators to use.
* @param invalidClass CSS class for invalid elements, or false if none should be set.
* @param invalidClass CSS class for invalid elements, or null if none should be set.
*/
public constructor(
validators: ValidatorDictionary,
invalidClass: string | false = "invalid"
invalidClass: string | null = "invalid"
) {
this.#map = new Map(Object.entries(validators));
this.#invalidClass = invalidClass;
Expand Down Expand Up @@ -73,10 +73,10 @@ export class Ok {
}
if (result) {
setCustomValidity(element, "");
if (this.#invalidClass != false) {
if (this.#invalidClass != null) {
element.classList.remove(this.#invalidClass);
}
} else if (this.#invalidClass != false) {
} else if (this.#invalidClass != null) {
element.classList.add(this.#invalidClass);
}

Expand Down

0 comments on commit f5290f2

Please sign in to comment.