validate json schema sent from request body to an api

hi all, im trying to send a request from postman to asp net api, but the net api need to validate the schema value pass from the postman request body, how can we validate the value "theValidSchemaValueToAnAPI"? i understand if we want to validate a model state, we put a "Required" data annotation, but validating the value doesnt seem to work..
public class NoteItem
{
private IList<string> _schemas = new List<string> { "theValidSchemaValueToAnAPI" };
[Required]
public IList<string> schemas { get { return _schemas; } set { _schemas = value; } }
public string noteId{ get; set; }
public string userId { get; set; }
}
public class NoteItem
{
private IList<string> _schemas = new List<string> { "theValidSchemaValueToAnAPI" };
[Required]
public IList<string> schemas { get { return _schemas; } set { _schemas = value; } }
public string noteId{ get; set; }
public string userId { get; set; }
}
2 Replies
Saber
Saber4y ago
sounds like you should use something like fluent validation instead
hellounlimited
hellounlimitedOP4y ago
ohh okay.. thank you! i'll check this out and try it

Did you find this page helpful?