diff options
author | 2018-07-24 17:34:04 +0300 | |
---|---|---|
committer | 2018-07-25 11:39:10 +0300 | |
commit | a52d50e788792a63e97a9176ab319d53db7a2853 (patch) | |
tree | b1c2222cacf4b8192aea16d1e0315b1f005c5347 /sdc-workflow-designer-ui/src/app/shared/input/validators.ts | |
parent | 3c2665debb400aef7f0ed9e235698d2ff9f859db (diff) |
Replaced old implementation at root
Old project files and directories has been moved
under 'deprecated-workflow-designer'. The old project
is not built by the CI anymore, but can be still built manually.
New modules/directories have been moved up and integrated with
the CI system.
Change-Id: I1528c792bcbcce9e50bfc294a1328a20e72c91cf
Issue-ID: SDC-1559
Signed-off-by: vempo <vitaliy.emporopulo@amdocs.com>
Diffstat (limited to 'sdc-workflow-designer-ui/src/app/shared/input/validators.ts')
-rw-r--r-- | sdc-workflow-designer-ui/src/app/shared/input/validators.ts | 147 |
1 files changed, 0 insertions, 147 deletions
diff --git a/sdc-workflow-designer-ui/src/app/shared/input/validators.ts b/sdc-workflow-designer-ui/src/app/shared/input/validators.ts deleted file mode 100644 index 6a4e799d..00000000 --- a/sdc-workflow-designer-ui/src/app/shared/input/validators.ts +++ /dev/null @@ -1,147 +0,0 @@ -import {AbstractControl, ValidationErrors} from '@angular/forms';
-
-export function inRangeValidator(in_range: number[]): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- const value = parseFloat(control.value);
- if (isNaN(value) || value > in_range[1] || value < in_range[0]) {
- control.setErrors({
- in_range: true
- });
- return {
- in_range: true
- }
- } else {
- return null;
- }
- }
-}
-
-export function greaterOrEqualValidator(max: string): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- const value = parseFloat(control.value);
- const maxValue: any = parseFloat(max);
- if (!isNaN(maxValue) && (isNaN(value) || value < maxValue)) {
- control.setErrors({
- greater_or_equal: true
- });
- return {
- greater_or_equal: true
- }
- } else {
- return null;
- }
- }
-}
-
-export function lessOrEqualValidator(min: string): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- const value = parseFloat(control.value);
- const minValue: any = parseFloat(min);
- if (!isNaN(minValue) && (isNaN(value) || value > minValue)) {
- control.setErrors({
- less_or_equal: true
- });
- return {
- less_or_equal: true
- }
- } else {
- return null;
- }
- }
-}
-
-export function greaterThanValidator(max: string): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- const value = parseFloat(control.value);
- const maxValue: any = parseFloat(max);
- if (!isNaN(maxValue) && (isNaN(value) || value <= maxValue)) {
- control.setErrors({
- greater_than: true
- });
- return {
- greater_than: true
- }
- } else {
- return null;
- }
- }
-}
-
-export function lessThanValidator(min: string): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- const value = parseFloat(control.value);
- const minValue: any = parseFloat(min);
- if (!isNaN(minValue) && (isNaN(value) || value >= minValue)) {
- control.setErrors({
- less_than: true
- });
- return {
- less_than: true
- }
- } else {
- return null;
- }
- }
-}
-
-export function equalValidator(value: any): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- if (control.value != value) {
- control.setErrors({
- equal: true
- });
- return {
- equal: true
- }
- } else {
- return null;
- }
- }
-}
-
-export function lengthValidator(length: number): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- if (control.value && control.value.length !== length) {
- control.setErrors({
- length: true
- });
- return {
- length: true
- }
- } else {
- return null;
- }
- }
-}
-
-export function floatValidator(): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- let floatPattern = /^(-?\d+)(\.\d+)?$/;
- if (control.value && !floatPattern.test(control.value)) {
- control.setErrors({
- float: true
- });
- return {
- float: true
- }
- } else {
- return null;
- }
- }
-}
-
-export function integerValidator(): ValidationErrors|null {
- return (control: AbstractControl): ValidationErrors => {
- let integerPattern = /^-?\d+$/;
- if (control.value && !integerPattern.test(control.value)) {
- control.setErrors({
- integer: true
- });
- return {
- integer: true
- }
- } else {
- return null;
- }
- }
-}
\ No newline at end of file |