Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow the Resource interface in validateAsync factory #69443

Description

@benjavicente

Which @angular/* package(s) are relevant/related to the feature request?

forms

Description

Currently validateAsync resource factory expects a ResourceRef. At runtime, it works with the base Resource interface. The only thing outside the Resource interface that it handles is ResourceRef reloading, but that has optional chaining for objects that do not have the .reloadmethod.

const keys = this.logicNode.logic.getMetadataKeys();
for (const key of keys) {
if (key[IS_ASYNC_VALIDATION_RESOURCE]) {
const resource = this.metadata(key)! as Resource<unknown> &
Partial<Pick<WritableResource<unknown>, 'reload'>>;
resource.reload?.();
}
}

Proposed solution

Change the factory type to accept a Resource interface instead of the larger ResourceRef interface.

This would make it easier for external libraries to work with async validation.

Alternatives considered

A new interface that extends Resource and adds only the reload method. WritableResource could extend that interface.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: formsgemini-triagedLabel noting that an issue has been triaged by gemini

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions