-
Notifications
You must be signed in to change notification settings - Fork 12
/
parameter.go
29 lines (23 loc) · 1.1 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
// Copyright [2021] - [2022], AssetMantle Pte. Ltd. and the code contributors
// SPDX-License-Identifier: Apache-2.0
package mint_enabled
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"
"github.com/AssetMantle/schema/go/properties/base"
constantProperties "github.com/AssetMantle/schema/go/properties/constants"
baseHelpers "github.com/AssetMantle/modules/helpers/base"
)
var ID = constantProperties.MintEnabledProperty.GetKey()
var Parameter = baseParameters.NewParameter(base.NewMetaProperty(ID, baseData.NewBooleanData(false)))
func validator(i interface{}) error {
switch value := i.(type) {
case string:
_, err := baseData.PrototypeBooleanData().FromString(value)
return err
default:
return errorConstants.IncorrectFormat.Wrapf("incorrect type for mintEnabled parameter, expected %s type as string, got %T", baseData.NewBooleanData(false).GetTypeID().AsString(), i)
}
}
var ValidatableParameter = baseHelpers.NewValidatableParameter(Parameter, validator)