Function sdk_agent::helper::validate_name
source · Examples found in repository?
src/lib.rs (line 32)
28 29 30 31 32 33 34 35 36 37 38 39
pub fn send_request(ctx: Context<SendRequest>, request: Request) -> Result<()> {
let s = request.name();
let name = String::from_utf8(s.to_vec()).unwrap();
if validate_name(&name.as_bytes()) == false {
return err!(AgentError::InvalidName);
}
let req = &mut ctx.accounts.request.load_init()?;
req.requester = ctx.accounts.owner.to_account_info().key();
req.request = request;
Ok(())
}