Skip to content

Instantly share code, notes, and snippets.

@pranavkm
Created July 15, 2020 04:14
Show Gist options
  • Save pranavkm/64c55c922b9d607ea2df5d037555e8be to your computer and use it in GitHub Desktop.
Save pranavkm/64c55c922b9d607ea2df5d037555e8be to your computer and use it in GitHub Desktop.
public record Person([FromRoute][Required][StringLength(1, 8)] string id);
public record Person
{
public Person(string id) => Id = id;
[FromRoute][Required][StringLength(1, 8)]
public string Id { get; init; }
}
public class Person
{
public Person(string id) => UserId = id;
[FromRoute][Required][StringLength(1, 8)]
public string UserId { get; }
}
public class Person
{
private string _id;
public Person([JsonProperty("UserId")][MaxLength(4)] string id) => _id = id;
}
public class Person
{
public Person([Required][StringLength(1, 8)] string id) => UserId = int.Parse(id);
[Range(1, 9999)]
public int UserId { get; }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment