Skip to content

Commit

Permalink
Move addNoValidate to this.options
Browse files Browse the repository at this point in the history
  • Loading branch information
dahlbyk committed Aug 13, 2023
2 parents 3f6eeb6 + 6095ba5 commit e3d0ff4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ export class MvcValidationProviders {
export interface ValidationServiceOptions {
watch: boolean;
root: ParentNode;
addNoValidate: boolean;
}

/**
Expand Down Expand Up @@ -958,6 +959,9 @@ export class ValidationService {
for (let i = 0; i < inputs.length; i++) {
let input = inputs[i];
this.addInput(input);
if (this.options.addNoValidate) {
input.closest('form')?.setAttribute('novalidate', 'novalidate');
}
}
}

Expand Down Expand Up @@ -1192,11 +1196,13 @@ export class ValidationService {
private options: ValidationServiceOptions = {
root: document.body,
watch: false,
addNoValidate: true,
}

/**
* Load default validation providers and scans the entire document when ready.
* @param options.watch If set to true, a MutationObserver will be used to continuously watch for new elements that provide validation directives.
* @param options.addNoValidate If set to true (the default), a novalidate attribute will be added to the containing form in validate elemets.
*/
bootstrap(options?: Partial<ValidationServiceOptions>) {
Object.assign(this.options, options);
Expand Down

0 comments on commit e3d0ff4

Please sign in to comment.