@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix fdic: <https://example.org/fdic#> .
@prefix ex: <https://example.org/shapes#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

#################################################################
# 1. BankBranch must have rdf:type fdic:BankBranch
#################################################################
ex:BankBranchTypeCheck a sh:NodeShape ;
    sh:targetClass fdic:BankBranch ;
    sh:property [
        sh:path rdf:type ;
        sh:hasValue fdic:BankBranch ;
        sh:message "Each bank branch must have rdf:type fdic:BankBranch." ;
    ] .

#################################################################
# 2. mainOfficeFlag must be 0 or 1 (integer)
#################################################################
ex:MainOfficeFlagCheck a sh:NodeShape ;
    sh:targetClass fdic:BankBranch ;
    sh:property [
        sh:path fdic:mainOfficeFlag ;
        sh:datatype xsd:integer ;
        sh:in ( 0 1 ) ;
        sh:message "mainOfficeFlag must be either 0 (Branch) or 1 (Main Office)." ;
    ] .

#################################################################
# 3. stateCode must be a valid 2-letter U.S. code
#################################################################
ex:StateCodeValidation a sh:NodeShape ;
    sh:targetClass fdic:BankBranch ;
    sh:property [
        sh:path fdic:stateCode ;
        sh:in (
            "AK" "AL" "AR" "AS" "AZ" "CA" "CO" "CT" "DC" "DE" "FL"
            "GA" "GU" "HI" "IA" "ID" "IL" "IN" "KS" "KY" "LA" "MA"
            "MD" "ME" "MI" "MN" "MO" "MP" "MS" "MT" "NC" "ND" "NE"
            "NH" "NJ" "NM" "NV" "NY" "OH" "OK" "OR" "PA" "PR" "RI"
            "SC" "SD" "TN" "TX" "UT" "VA" "VI" "VT" "WA" "WI" "WV"
            "WY"
        ) ;
        sh:message "stateCode must be a valid U.S. state/territory code." ;
    ] .

#################################################################
# 4. stateName must not be blank
#################################################################
ex:StateNamePresenceCheck a sh:NodeShape ;
    sh:targetClass fdic:BankBranch ;
    sh:property [
        sh:path fdic:stateName ;
        sh:minLength 1 ;
        sh:message "stateName must not be blank (used to detect foreign branches)." ;
    ] .

#################################################################
# 5. acquisitionDate, establishedDate, and runDate must be valid xsd:date
#################################################################
ex:DateFormatCheck a sh:NodeShape ;
    sh:targetClass fdic:BankBranch ;
    
    sh:property [
        sh:path fdic:acquisitionDate ;
        sh:datatype xsd:date ;
        sh:message "acquisitionDate must be a valid xsd:date." ;
    ] ;
    sh:property [
        sh:path fdic:establishedDate ;
        sh:datatype xsd:date ;
        sh:message "establishedDate must be a valid xsd:date." ;
    ] ;
    sh:property [
        sh:path fdic:runDate ;
        sh:datatype xsd:date ;
        sh:message "runDate must be a valid xsd:date." ;
    ] .