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 plain ValidationAttribute for model-based validation #84

Merged
merged 1 commit into from
Dec 18, 2020

Conversation

Atrejoe
Copy link
Contributor

@Atrejoe Atrejoe commented Nov 18, 2020

For simple non-MVC Web API clients

@TimothyMeadows
Copy link
Owner

What is the purpose of this?

@Atrejoe
Copy link
Contributor Author

Atrejoe commented Nov 27, 2020

It re-uses the validation logic without using the form-generating logic.
In my case I have a plain Web API that is being used by an (Angular) client.

Attribute-based validation is used, and it would be nice if Captcha input can be validated in the same way.

@Atrejoe
Copy link
Contributor Author

Atrejoe commented Nov 27, 2020

Sample usage:

/// <summary>
/// Performs password recovery request.
/// </summary>
/// <returns>A status code only.</returns>
/// <response code="200">User is known and password recovery request has been initiated <br/>
/// or
/// <br/>
/// user is not known (not exposing account stataus to unaiuthenticated users).</response>
/// <response code="400"><paramref name="emailAddress"/> or <paramref name="captchaCode"/> were not specified or invalid.</response>
[HttpPost]
[Route("password")]
[ActionName("resetrequest")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
public async Task<StatusCodeResult> ResetPassword(
	[Required, EmailAddress] string emailAddress,
	[Required, CaptchaResponse] string captchaCode) {

	//do logic here: in this case send a password recovery email when the accounts exists

	return Ok();
}

@TimothyMeadows TimothyMeadows merged commit 552cd0a into TimothyMeadows:master Dec 18, 2020
@TimothyMeadows
Copy link
Owner

Merged, will test this weekend for nuget update.

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.

2 participants