Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Many Meanings of Message Validation
public class OrderItem
{
public string ItemId { get; set; }
public int Amount { get; set; }
}
public class OrderItemValidator : AbstractValidator<OrderItem>
{
public OrderItemValidator()
{
RuleFor(item => item.ItemId).Matches(@"\w+\-\w+\-\w+");
RuleFor(item => item.Amount).GreaterThan(0).LessThanOrEqualTo(100);
}
}
var orderItem = new OrderItem();
var validator = new OrderItemValidator();
var result = validator.Validate(orderItem);
...
paths:
# Path definition
/pets:
get:
description: Returns all pets from the system that the user has access to
responses:
'200':
description: A list of pets.
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/pet'
...
components:
...
schemas:
# Schema definition
pet:
type: object
required:
- name
properties:
name:
type: string
address:
$ref: '#/components/schemas/Address'
age:
type: integer
format: int32
minimum: 0
...
{
"orderId": 123,
"items": [
{
"itemId": "pizza-hwaiian-large",
"amount": 1
},
{
"itemId": "water-sparkling-medium",
"amount": 1
}
]
}
<description>
...
<types>
// Definition of data contract
</types>
...
<interface>
// Definition of service contract
</interface>
...
<service>
// Definition of service endpoint
</service>
...
</description>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.