Skip to content

Problem with async validators #20

@zoomisen

Description

@zoomisen

I'm trying to use an async validator combined with your module, my api return a 200 response if email is unique and a 400 response if it's already in use.

Have you tried using async validators?

I think your module needs some way to notice if validity has changed after an async validator has been deferred.

Or do you have an working example.

The field am testing with looks like this:

<div class="form-group">
		<label for="email">E-mail</label>
		<div class="input-group">
				<div class="input-group-addon"><i class="fa fa-envelope"></i></div>
				<input ng-model="admin.email" id="email" name="email" class="form-control" type="email" required is-unique-admin-email ng-model-options="{debounce: 250}" />
		</div>
</div>
ctrl.$asyncValidators.uniqueAdminEmail = function(modelValue, viewValue)
{
	return $http({
		url: "/validate/unique-admin-email?email=" + value,
		method: "GET",
	})
		.then(function()
		{
			return $q.resolve();
		}, function()
		{
			return $q.reject();
		});
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions