comline/core/examples/simple.ids

81 lines
1.4 KiB
Plaintext
Raw Normal View History

2023-08-28 14:09:31 -05:00
namespace examples::thing::simple
2023-06-15 07:10:20 -05:00
const AGREEMENT_KEY: string = "agreement_key"
validator PasswordCheck {
2023-08-28 14:09:31 -05:00
min_chars: u32 = 16
max_chars: u32 = 60
validate = {
assert_valid(
self.parameters.0,
StringBounds(params.min_chars params.max_chars)
// StringBounds(min_chars=self.min_chars max_chars=self.max_chars)
)
}
2023-06-15 07:10:20 -05:00
}
2023-08-28 14:09:31 -05:00
2023-06-15 07:10:20 -05:00
@settings(versioned=False validate_fields=False)
struct Credentials {
2023-06-15 07:10:20 -05:00
@validators([StringBounds(min_chars=8 max_chars=16)])
1# username: str = "test"
@validators=[PasswordCheck]
2023-06-15 07:10:20 -05:00
2# password: str
}
2023-06-15 07:10:20 -05:00
struct CredentialsOther {
@parameters.0.validators=[StringBounds(min_chars=8 max_chars=16]
#1 username: union(str null) = "test" | null
@validators=([PasswordCheck()])
#2 password: str
2023-06-15 07:10:20 -05:00
}
2023-06-15 07:10:20 -05:00
enum RegisterStatus {
Ok
UsernameTaken
}
error TellBackError {
message = "Could not get the provider to tell \"{self.back}\" back"
1# back: str
2023-06-15 07:10:20 -05:00
}
@provider=Server
protocol Registry {
2023-06-15 07:10:20 -05:00
@argument.0.username.validate=true
#timeout_ms=100
#cooldown_ms=200
function register(Credentials) returns RegisterStatus
@return.0.validators=[StringBounds(min_chars=8)]
function my_username() returns str
@return.0.validators=[StringBounds(min_chars=8)]
function tell_back(str = "back") returns str throws TellBackError
}
2023-06-15 07:10:20 -05:00
struct TellBackResponse {
}
@provider=Server
protocol Events {
2023-06-15 07:10:20 -05:00
async function poke()
}