File

src/lib/components/required-field-validator/required-field-validator.component.ts

Extends

BaseValidatorComponent

Metadata

Index

Properties
Methods
Inputs
Accessors

Constructor

constructor(wmService: WebMapService, refChange: ChangeDetectorRef, render2: Renderer2, elem: ElementRef, webComponents: WebComponentsService, validatorService: BaseValidatorService, bringTopServ1: BringTopService)

Creates an instance of RequiredFieldValidatorComponent.

Parameters :
Name Type Optional
wmService WebMapService No
refChange ChangeDetectorRef No
render2 Renderer2 No
elem ElementRef No
webComponents WebComponentsService No
validatorService BaseValidatorService No
bringTopServ1 BringTopService No

Inputs

initialValue
Type : string

Gets/sets the initial value.

controlToValidate
Type : string
Inherited from BaseValidatorComponent

Gets/sets the Control to Validate and notify the service.

errorMessage
Type : string
Inherited from BaseValidatorComponent

Gets/sets the error message.

Methods

validateControl
validateControl(controlToValidate: string, expressionToValidate: string | number | Date)
Inherited from BaseValidatorComponent

Compare the expressionToValidate against the initial value to validate that they are different.

Parameters :
Name Type Optional
controlToValidate string No
expressionToValidate string | number | Date No
Returns : boolean

if the expressionToValidate is different from the initial value.

displayMessage
displayMessage()
Inherited from BaseValidatorComponent

If the text property is defined, it has to be shown instead of the error message

Returns : string

The property to display

ngOnDestroy
ngOnDestroy()
Inherited from BaseValidatorComponent

OnDestroy lifecycle hook, removes itself from the service.

Returns : void
ngOnInit
ngOnInit()
Inherited from BaseValidatorComponent

OnInit lifecycle hook, adds itself to the service.

Returns : void

Properties

Protected initialValueInternal
Type : string
Default value : ''

Property with the initial value to validate against

Protected controlToValidateInternal
Type : string
Default value : ''
Inherited from BaseValidatorComponent

Property with the Id of the control to validate.

Private displayInternal
Default value : ValidatorDisplay.Static
Inherited from BaseValidatorComponent

Internal property for handle type of Display in component

Protected errorMessageInternal
Type : string
Default value : ''
Inherited from BaseValidatorComponent

Property with the error message.

Protected hiddenInternal
Default value : true
Inherited from BaseValidatorComponent

Property with the visibility of the component.

Protected validationGroupInternal
Type : string
Default value : ''
Inherited from BaseValidatorComponent

Property with the validationGroup

@memberof BaseValidatorComponent

Protected validationSuccessInternal
Default value : false
Inherited from BaseValidatorComponent

Property with that indicates if the validation is passed.

Accessors

initialValue
getinitialValue()
setinitialValue(initialValue: string)

Gets/sets the initial value.

Parameters :
Name Type Optional
initialValue string No
Returns : void
import { WebMapService } from '@mobilize/angularclient';
import { BringTopService, dataTransfer } from '@mobilize/base-components';
import {
  BaseValidatorService,
  WebComponentsService
} from '@mobilize/winforms-components';
import {
  Component,
  Optional,
  ElementRef,
  Input,
  Renderer2,
  ChangeDetectorRef
} from '@angular/core';
import { BaseValidatorComponent } from '../base-validator/BaseValidator';
import { WebFormsBaseValidatorService } from '../../services/base-validator-service/web-forms-base-validator.service';
import { ExceptionHandlerClass, ErrorCodes } from '@mobilize/webmap-core';
import { ValidatorDisplay } from '../../contracts/ValidatorDisplay';

@Component({
  selector: 'wm-required-field-validator',
  templateUrl: './required-field-validator.component.html',
  styleUrls: ['./required-field-validator.component.scss'],
  inputs: ['model'],
  providers: [
    { provide: BaseValidatorService, useExisting: WebFormsBaseValidatorService }
  ]
})
@dataTransfer(['requiredVal'])
@ExceptionHandlerClass(ErrorCodes.Winforms)
export class RequiredFieldValidatorComponent extends BaseValidatorComponent {
  /**
   * Property with the initial value to validate against
   *
   * @memberof RequiredFieldValidatorComponent
   */
  protected initialValueInternal = '';

  /**
   * Creates an instance of RequiredFieldValidatorComponent.
   *
   * @param {WebMapService} wmService
   * @param {ChangeDetectorRef} refChange
   * @param {Renderer2} render2
   * @param {ElementRef} elem
   * @param {WebComponentsService} webComponents
   * @param {BringTopService} bringTopServ1
   * @memberof RequiredFieldValidatorComponent
   */
  constructor(
    private wmService: WebMapService,
    refChange: ChangeDetectorRef,
    render2: Renderer2,
    elem: ElementRef,
    webComponents: WebComponentsService,
    validatorService: BaseValidatorService,
    @Optional() bringTopServ1: BringTopService
  ) {
    super(
      refChange,
      render2,
      elem,
      webComponents,
      validatorService,
      bringTopServ1
    );
  }

  /**
   * Gets/sets the initial value.
   *
   * @memberof RequiredFieldValidatorComponent
   */
  @Input()
  set initialValue(initialValue: string) {
    this.initialValueInternal = initialValue;
  }

  get initialValue() {
    return this.model.InitialValue ?? this.initialValueInternal;
  }

  /**
   * Compare the expressionToValidate against the initial value
   * to validate that they are different.
   *
   * @param expressionToValidate
   * @returns if the expressionToValidate is different from the initial value.
   * @memberof RequiredFieldValidatorComponent
   */
  validateControl(
    controlToValidate: string,
    expressionToValidate: string | number | Date
  ): boolean {
    this.validationSuccessInternal = expressionToValidate !== this.initialValue;

    if (this.Display !== ValidatorDisplay.None) {
      this.hidden = this.validationSuccessInternal;
    } else {
      this.hidden = true;
    }

    return this.validationSuccessInternal;
  }
}
<span [hidden]="hidden" [ngClass]="class">{{displayMessage()}}</span>

./required-field-validator.component.scss

Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""