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

added file last modified validator #2096

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

labibismaiel
Copy link

File last modified date validator

This validator can be used to ensure that the uploaded file was last modified within a specific date range. This can be useful in scenarios where you want to ensure that users are uploading recent files, such as recent documents, photos, or reports.

To use this validator, you would provide the desired date range as parameters when adding it to a form element:

const fileInput = document.querySelector('lion-input-file');
const validator = new  FileLastModifiedDateValidator({ 
	startDate: new  Date('2022-01-01'),
	endDate: new  Date('2023-01-01') 
});
fileInput.addValidator(validator);

This would ensure that only files modified between January 1, 2022, and January 1, 2023, are considered valid.

@changeset-bot
Copy link

changeset-bot bot commented Oct 16, 2023

⚠️ No Changeset found

Latest commit: 905bedf

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@gerjanvangeest
Copy link
Member

gerjanvangeest commented Oct 17, 2023

Hi @labibismaiel,

Thanks for the PR 💪 !!

  • Since its an input-file specific valdator, could you move this code to the input-file?
  • Add a changeset npm run changset, so the change will end up in our changelog?
  • Fix the failing tests
  • Add documentation
  • Sign the CLA

/**
* Checks if the file's last modified date is within the specified range.
* @param {Date} fileLastModifiedDate - The file's last modified date.
* @param {Date} startDate - The start date of the allowed range.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param {Date} startDate - The start date of the allowed range.
* @param {Date} minDate - The start date of the allowed range.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this inline with other date validators

* Checks if the file's last modified date is within the specified range.
* @param {Date} fileLastModifiedDate - The file's last modified date.
* @param {Date} startDate - The start date of the allowed range.
* @param {Date} endDate - The end date of the allowed range.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @param {Date} endDate - The end date of the allowed range.
* @param {Date} maxDate - The end date of the allowed range.

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

Successfully merging this pull request may close these issues.

None yet

3 participants