-
Notifications
You must be signed in to change notification settings - Fork 12
/
parameter.go
34 lines (28 loc) · 1.33 KB
/
parameter.go
1
2
3
4
5
6
7
8
9
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
// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors
// SPDX-License-Identifier: Apache-2.0
package max_order_life
import (
baseData "github.com/AssetMantle/schema/go/data/base"
errorConstants "github.com/AssetMantle/schema/go/errors/constants"
baseParameters "github.com/AssetMantle/schema/go/parameters/base"
baseProperties "github.com/AssetMantle/schema/go/properties/base"
constantProperties "github.com/AssetMantle/schema/go/properties/constants"
baseTypes "github.com/AssetMantle/schema/go/types/base"
baseHelpers "github.com/AssetMantle/modules/helpers/base"
)
var ID = constantProperties.MaxOrderLifeProperty.GetKey()
var Parameter = baseParameters.NewParameter(baseProperties.NewMetaProperty(ID, baseData.NewHeightData(baseTypes.NewHeight(43210))))
func validator(i interface{}) error {
switch value := i.(type) {
case string:
if height, err := baseData.PrototypeHeightData().FromString(value); err != nil {
return err
} else {
err = height.(*baseData.HeightData).ValidateBasic()
return err
}
default:
return errorConstants.IncorrectFormat.Wrapf("incorrect type for maxOrderLife parameter, expected %s type as string, got %T", baseData.NewHeightData(baseTypes.NewHeight(0)).GetTypeID().AsString(), i)
}
}
var ValidatableParameter = baseHelpers.NewValidatableParameter(Parameter, validator)