comline/examples/simple.ids
2023-06-24 04:16:35 +01:00

84 lines
1.6 KiB
Plaintext

namespace examples.thing.simple
const AGREEMENT_KEY: string = "agreement_key"
@min_chars=0 max_chars=1024
validator StringBounds {
assert_error(
value.length > params.max_chars or value.length < params.min_chars,
"String {value.name} must be more than {params.min_chars} and less than {params.max_chars}"
)
}
@min_chars=16 max_chars=60
validator PasswordCheck {
assert_valid(
self.parameters.0,
StringBounds(min_chars=params.min_chars max_chars=params.max_chars
)
}
@settings(versioned=False validate_fields=False)
struct Credentials {
@validators([StringBounds(min_chars=8 max_chars=16)])
1# username: str = "test"
@validators=[PasswordCheck]
2# password: str
}
struct CredentialsOther {
@parameters.0.validators=[StringBounds(min_chars=8 max_chars=16]
#1 username: union(str null) = "test" | null
@validators=([PasswordCheck()])
#2 password: str
}
enum RegisterStatus {
Ok
UsernameTaken
}
error TellBackError {
message = "Could not get the provider to tell \"{self.back}\" back"
1# back: str
}
@provider=Server
protocol Registry {
@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
}
struct TellBackResponse {
}
@provider=Server
protocol Events {
async function poke()
}