Skip to content

Conversation

@rab1prasad
Copy link
Contributor

@rab1prasad rab1prasad commented Jun 26, 2025

  • Currently in input component we don't have support for async validators need to add async validators support in input box.
  • Add support for asynchronous input validator.
  • Change return type of custom validator for input component.

Dev proof:
https://drive.google.com/file/d/1dEH7HftNeAqsOeqesCC6NrqDU4fseYFf/view?usp=sharing

@sinha-sahil sinha-sahil force-pushed the release branch 11 times, most recently from 99c6c14 to 7acf429 Compare July 18, 2025 14:40
@rab1prasad rab1prasad marked this pull request as draft July 31, 2025 07:31
@rab1prasad rab1prasad marked this pull request as ready for review July 31, 2025 07:32
@sinha-sahil sinha-sahil force-pushed the release branch 16 times, most recently from 766850e to 4225408 Compare August 6, 2025 03:46
@murdore murdore force-pushed the BZ-42256-add-support-for-asynchronous-validator-in-input branch from 6f378af to 5c06656 Compare September 16, 2025 07:09
$: state = getValidationState(properties) as ValidationState;
let state: ValidationState = 'InProgress';
$: {
Copy link
Collaborator

Choose a reason for hiding this comment

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

avoid adding reactive blocks

Choose a reason for hiding this comment

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

Done

@itz-PrathamMittal itz-PrathamMittal force-pushed the BZ-42256-add-support-for-asynchronous-validator-in-input branch from 5c06656 to a837797 Compare September 24, 2025 10:39
for (const validator of customValidators) {
const currentResult = await Promise.resolve(validator(inputValue, validationResult));
if (currentResult === 'Invalid') {
validationResult = 'Invalid';
Copy link
Contributor

Choose a reason for hiding this comment

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

once you reach invalid state, you can just return the result. no need to iterate over remaining validators

Choose a reason for hiding this comment

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

done

@itz-PrathamMittal itz-PrathamMittal force-pushed the BZ-42256-add-support-for-asynchronous-validator-in-input branch from a837797 to 4564494 Compare September 25, 2025 08:40
// For making this function reactive, prop was passed as param
function getValidationState(prop: InputProperties): ValidationState {
const valueValidation: ValidationState = validateInput(
async function getValidationState(prop: InputProperties): Promise<ValidationState> {
Copy link
Contributor

Choose a reason for hiding this comment

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

async function getValidationState(prop: InputProperties): Promise<ValidationState> {
    const valueValidation: ValidationState = await validateInput(
      prop.value,
      prop.dataType,
      prop.validationPattern,
      prop.inProgressPattern,
      prop.validators
    );
    if (
      valueValidation === 'InProgress' &&
      prop.value.length > 0 &&
      inputElement &&
      inputElement !== document.activeElement
    ) {
      state = 'Invalid';
    } else {
      state = valueValidation;
    }
  

Copy link
Contributor

Choose a reason for hiding this comment

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

$: getValidationState(properties);

github-actions bot and others added 2 commits October 27, 2025 13:54
- Add support for asynchronous input validator.
- Change return type of custom validator for input component.
@itz-PrathamMittal itz-PrathamMittal force-pushed the BZ-42256-add-support-for-asynchronous-validator-in-input branch from 4564494 to db203c3 Compare October 27, 2025 14:28
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.

10 participants