Last active
October 7, 2019 23:05
-
-
Save justinyoo/c5cd857042083f4c84bff28e4a7899e9 to your computer and use it in GitHub Desktop.
Many Meanings of Message Validation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
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 | |
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"orderId": 123, | |
"items": [ | |
{ | |
"itemId": "pizza-hwaiian-large", | |
"amount": 1 | |
}, | |
{ | |
"itemId": "water-sparkling-medium", | |
"amount": 1 | |
} | |
] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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