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

Revamp validators type #12

Merged
merged 3 commits into from
Oct 17, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ export interface Textarea extends InputElementBase {
}

export interface TextareaProperties extends InputElementBaseProperties{
forms_ExternalSystemsFieldMappings: string[];
autoComplete: string;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Validators } from "../../validators/Validators";
import { ValidatorBase } from "../../validators/base/";
import { FormElementBase, FormElementPropertiesBase } from "./FormElementBase";

/**
Expand All @@ -11,6 +11,6 @@ export interface ValidatableElementBase extends FormElementBase {
}

export interface ValidatableElementBaseProperties extends FormElementPropertiesBase {
validators: Validators[]
validators: ValidatorBase[]
validatorMessages: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { InternalElementValidatorBase, ValidatorModelBase } from "./base";

export interface AllowedExtensionsValidator extends InternalElementValidatorBase{
model: AllowedExtensionsValidatorModel
}

export interface AllowedExtensionsValidatorModel extends ValidatorModelBase {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { InternalElementValidatorBase } from "./base";

export interface CaptchaValidator extends InternalElementValidatorBase {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RegularExpressionValidator } from "./RegularExpressionValidator";

export interface DateDDMMYYYYValidator extends RegularExpressionValidator {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RegularExpressionValidator } from "./RegularExpressionValidator";

export interface DateMMDDYYYYValidator extends RegularExpressionValidator {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RegularExpressionValidator } from "./RegularExpressionValidator";

export interface DateYYYYMMDDValidator extends RegularExpressionValidator {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RegularExpressionValidator } from "./RegularExpressionValidator";

export interface EmailValidator extends RegularExpressionValidator{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RegularExpressionValidator } from "./RegularExpressionValidator";

export interface IntegerValidator extends RegularExpressionValidator {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { InternalElementValidatorBase, ValidatorModelBase } from "./base";

export interface MaxFileSizeValidator extends InternalElementValidatorBase {
model: MaxFileSizeValidationModel
}

export interface MaxFileSizeValidationModel extends ValidatorModelBase {
sizeInBytes: number
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ElementValidatorBase } from "./base";

export interface NumericValidator extends ElementValidatorBase {
isValidNumber: boolean
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RegularExpressionValidatorBase } from "./base";

export interface PositiveIntegerValidator extends RegularExpressionValidatorBase {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RegularExpressionValidatorBase } from "./base";

export interface RegularExpressionValidator extends RegularExpressionValidatorBase{
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ElementValidatorBase } from "./base";

export interface RequiredValidator extends ElementValidatorBase {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { RegularExpressionValidatorBase } from "./base";

export interface UrlValidator extends RegularExpressionValidatorBase {

}
14 changes: 0 additions & 14 deletions src/@optimizely/forms-sdk/src/models/validators/Validators.ts

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface ElementValidatorBase {
validationOrder: number,
description: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { ElementValidatorBase } from "./ElementValidatorBase";

export interface InternalElementValidatorBase extends ElementValidatorBase{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { ElementValidatorBase } from "./ElementValidatorBase";
import { ValidatorModelBase } from "./ValidatorsBase";

export interface RegularExpressionValidatorBase extends ElementValidatorBase{
model: RegularExpressionValidatorModel
}

export interface RegularExpressionValidatorModel extends ValidatorModelBase {
jsPattern: string,
dotNetPattern: string
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* Base class for validators
*/
export interface ValidatorBase {
type: string
description: string
model: ValidatorModelBase
}

export interface ValidatorModelBase {
message: string
validationCssClass: string
additionalAttributes: any
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from "./ValidatorsBase";
export * from "./InternalElementValidatorBase";
export * from "./RegularExpressionValidatorBase";
export * from "./ElementValidatorBase";
17 changes: 14 additions & 3 deletions src/@optimizely/forms-sdk/src/models/validators/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
export * from "./Validators";
export * from "./models/EmailValidatorModel";
export * from "./models/RequiredValidatorModel";
export * from "./base"
export * from "./AllowedExtensionsValidator";
export * from "./CaptchaValidator";
export * from "./DateDDMMYYYYValidator";
export * from "./DateMMDDYYYYValidator";
export * from "./DateYYYYMMDDValidator";
export * from "./EmailValidator";
export * from "./IntegerValidator";
export * from "./MaxFileSizeValidator";
export * from "./NumericValidator";
export * from "./PositiveIntegerValidator"
export * from "./RegularExpressionValidator";
export * from "./RequiredValidator";
export * from "./UrlValidator";

This file was deleted.

This file was deleted.