User input contract
UserInput
Bases: BaseModel
A model representing the input data from the user, with validation for various fields.
Attributes:
Name | Type | Description |
---|---|---|
sales_agent |
str
|
The sales agent handling the deal. |
product |
str
|
The product being dealt with. |
account |
str
|
The account associated with the deal. |
unknow_customer |
Optional[str]
|
An optional field for unknown customer details. |
deal_stage |
str
|
The current stage of the deal. |
engage_date |
Optional[date]
|
The date when the deal was engaged. |
close_date |
Optional[date]
|
The date when the deal was closed. |
close_value |
Optional[NonNegativeFloat]
|
The value of the closed deal, if applicable. |
Source code in shared/contracts/user_input_contract.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
validate_close_date(value, info)
Validates the 'close_date' field to ensure it's provided for 'Won' or 'Lost' deal stages.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Optional[date]
|
The value of the 'close_date' field. |
required |
info
|
Additional information about the validation context. |
required |
Returns:
Type | Description |
---|---|
Optional[date]
|
Optional[date]: The validated value of 'close_date'. |
Raises:
Type | Description |
---|---|
ValueError
|
If 'close_date' is required but not provided for certain deal stages. |
Source code in shared/contracts/user_input_contract.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
validate_close_value(value, info)
Validates the 'close_value' field to ensure it's greater than 0 if the deal is 'Won'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Optional[NonNegativeFloat]
|
The value of the 'close_value' field. |
required |
info
|
Additional information about the validation context. |
required |
Returns:
Type | Description |
---|---|
Optional[NonNegativeFloat]
|
Optional[NonNegativeFloat]: The validated value of 'close_value'. |
Raises:
Type | Description |
---|---|
ValueError
|
If 'close_value' is less than or equal to 0 for a 'Won' deal stage. |
Source code in shared/contracts/user_input_contract.py
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
|
validate_date_difference(data)
Validates that the 'close_date' is later than or equal to the 'engage_date'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
UserInput
|
The instance of the class being validated. |
required |
Returns:
Name | Type | Description |
---|---|---|
UserInput |
UserInput
|
The validated instance of the class. |
Raises:
Type | Description |
---|---|
ValueError
|
If 'close_date' is earlier than 'engage_date'. |
Source code in shared/contracts/user_input_contract.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
|
validate_unknown_customer(value, info)
Validates the 'unknow_customer' field to ensure it's filled if the account is 'Other'.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
value
|
Optional[str]
|
The value of the 'unknow_customer' field. |
required |
info
|
Additional information about the validation context. |
required |
Returns:
Type | Description |
---|---|
Optional[str]
|
Optional[str]: The validated value of 'unknow_customer'. |
Raises:
Type | Description |
---|---|
ValueError
|
If 'unknow_customer' is required but not provided. |
Source code in shared/contracts/user_input_contract.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|