Skip to content

Commit

Permalink
Merge pull request #12 from episerver/feature/AFORM-3564-add-textarea
Browse files Browse the repository at this point in the history
Revamp validators type
  • Loading branch information
epi-qang2 authored Oct 17, 2023
2 parents 262018c + e129423 commit fab815d
Show file tree
Hide file tree
Showing 24 changed files with 127 additions and 44 deletions.
1 change: 0 additions & 1 deletion src/@optimizely/forms-sdk/src/models/elements/Textarea.ts
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
}
4 changes: 4 additions & 0 deletions src/@optimizely/forms-sdk/src/models/validators/base/index.ts
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.

0 comments on commit fab815d

Please sign in to comment.