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

"lessThan" and "greaterThan" validators not working correctly #601

Closed
maxiwer opened this issue Nov 17, 2022 · 1 comment
Closed

"lessThan" and "greaterThan" validators not working correctly #601

maxiwer opened this issue Nov 17, 2022 · 1 comment

Comments

@maxiwer
Copy link

maxiwer commented Nov 17, 2022

Describe the bug

I've created two properties of a component in an angular project, let's name them "lessDate" and "greaterDate". Placing them inside of FormBuilder's group constructor, I've started attaching validators for them - among them was RxwebValidators.lessThan validator:

form = this.fb.group({
    lessDate: [
      this.lessDate,
      [
        RxwebValidators.notEmpty(),
        RxwebValidators.lessThan({
          fieldName: 'greaterDate',
          message: this.translate.get('someErrorMessage'),
        }),
      ],
    ],
    greaterDate: [this.greaterDate, [RxwebValidators.notEmpty()]],
  });

My concern is - the "lessThan" validator doesn't work correctly for dates comparison.

Expected Behavior

"lessThan" validator correctly compares two dates.

To Reproduce

lessDate: any = new Date();
greaterDate: Date = new Date();

form = this.fb.group({
    lessDate: [
      this.lessDate,
      [
        RxwebValidators.notEmpty(),
        RxwebValidators.lessThan({
          fieldName: 'greaterDate',
          message: this.translate.get('someErrorMessage'),
        }),
      ],
    ],
    greaterDate: [this.greaterDate, [RxwebValidators.notEmpty()]],
  });

Package Version

@rxweb/reactive-form-validators@^2.1.7

@ajayojha
Copy link
Member

@maxiwer please use minDate & maxDate validator according to your need, instead lessThan & greaterThan.

Hence, I am closing this ticket as no further action is required on this :). feel free to create new ticket if there is any issue or have some queries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants