icydb-base 0.0.12

IcyDB — A type-safe, embedded ORM and schema system for the Internet Computer
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::{core::traits::Validator, prelude::*};

///
/// Utf8
///

#[validator]
pub struct Utf8;

impl Validator<[u8]> for Utf8 {
    fn validate(&self, bytes: &[u8]) -> Result<(), String> {
        std::str::from_utf8(bytes)
            .map(|_| ())
            .map_err(|_| "invalid utf-8 data".to_string())
    }
}