#[derive(Debug, Clone)]
pub enum SchemaType {
Fungible,
NonFungible,
Collectible,
Identity,
Custom(String),
}
#[derive(Debug, Clone)]
pub enum FieldType {
String,
Integer,
Boolean,
Binary,
Amount,
Hash,
Signature,
}
#[derive(Debug, Clone)]
pub struct Field {
pub name: String,
pub field_type: FieldType,
pub required: bool,
}
#[derive(Debug, Clone)]
pub struct Schema {
pub name: String,
pub schema_type: SchemaType,
pub fields: Vec<Field>,
pub version: String,
}
#[derive(Debug, Clone)]
pub struct Validation {
pub rules: Vec<String>,
pub schema_id: String,
}
impl Schema {
pub fn new(name: &str, schema_type: SchemaType) -> Self {
Self {
name: name.to_string(),
schema_type,
fields: Vec::new(),
version: "1.0".to_string(),
}
}
pub fn add_field(&mut self, field: Field) {
self.fields.push(field);
}
pub fn validate(&self) -> bool {
!self.fields.is_empty()
}
}