Skip to content

when I send data with Guid.Empty, the validator success validation instead of fail validation. #83954

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

Closed
RoderickIveans opened this issue Mar 27, 2023 · 3 comments

Comments

@RoderickIveans
Copy link

Description

when I send data with Guid.Empty, the validator success validation instead of fail validation.

Reproduction Steps

using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication2.Controllers;
[ApiController]
[Route("[controller]")]
public class FooController : ControllerBase
{
    [HttpPost]
    public FooModel Foo([FromBody] FooModel fooModel)
    {
        return fooModel;
    }
}

public class FooModel
{
    [Required(AllowEmptyStrings = false, DisallowAllDefaultValues = true)]
    public Guid? Id { get; set; }
}

Expected behavior

{
  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "Id": [
      "The Id field is required."
    ]
  },
  "traceId": "00-b7dcd87be3c66cde040e34fc685d4c7a-6a1eb125481c8a9f-00"
}

Actual behavior

{
  "id": "00000000-0000-0000-0000-000000000000"
}

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

@ghost ghost added untriaged New issue has not been triaged by the area owner area-System.ComponentModel.DataAnnotations labels Mar 27, 2023
@ghost
Copy link

ghost commented Mar 27, 2023

Tagging subscribers to this area: @jeffhandley
See info in area-owners.md if you want to be subscribed.

Issue Details

Description

when I send data with Guid.Empty, the validator success validation instead of fail validation.

Reproduction Steps

using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;

namespace WebApplication2.Controllers;
[ApiController]
[Route("[controller]")]
public class FooController : ControllerBase
{
    [HttpPost]
    public FooModel Foo([FromBody] FooModel fooModel)
    {
        return fooModel;
    }
}

public class FooModel
{
    [Required(AllowEmptyStrings = false, DisallowAllDefaultValues = true)]
    public Guid? Id { get; set; }
}

Expected behavior

{
  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",
  "title": "One or more validation errors occurred.",
  "status": 400,
  "errors": {
    "Id": [
      "The Id field is required."
    ]
  },
  "traceId": "00-b7dcd87be3c66cde040e34fc685d4c7a-6a1eb125481c8a9f-00"
}

Actual behavior

{
  "id": "00000000-0000-0000-0000-000000000000"
}

Regression?

No response

Known Workarounds

No response

Configuration

No response

Other information

No response

Author: RoderickIveans
Assignees: -
Labels:

area-System.ComponentModel.DataAnnotations, untriaged

Milestone: -

@stephentoub
Copy link
Member

Duplicate of #83797?

@eiriktsarpalis
Copy link
Member

Duplicate of #83797?

Yep. @RoderickIveans feel free to contribute to the conversation going on in the other issue. Thanks.

@eiriktsarpalis eiriktsarpalis closed this as not planned Won't fix, can't repro, duplicate, stale Mar 27, 2023
@ghost ghost removed the untriaged New issue has not been triaged by the area owner label Mar 27, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Apr 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants