| 1 | package Data::Sah::Type::BaseType; | ||
| 2 | |||
| 3 | # why name it BaseType instead of Base? because I'm sick of having 5 files named | ||
| 4 | # Base.pm in my editor (there would be Type::Base and the various | ||
| 5 | # Compiler::*::Type::Base). | ||
| 6 | |||
| 7 | 84 | ▶ | use 5.010; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | 84 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 9 | 84 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 84 | ▶ | use Data::Sah::Util::Role 'has_clause'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 84 | ▶ | use Role::Tiny; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | #use Sah::Schema::Common; | ||
| 14 | #use Sah::Schema::Sah; | ||
| 15 | |||
| 16 | 84 | our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY | |
| 17 | 84 | our $DATE = '2024-02-16'; # DATE | |
| 18 | 84 | our $DIST = 'Data-Sah'; # DIST | |
| 19 | 84 | our $VERSION = '0.917'; # VERSION | |
| 20 | |||
| 21 | 84 | our $sch_filter_elem = ['any', {of=>[ | |
| 22 | ['str', {req=>1}], | ||
| 23 | ['array', {req=>1, len=>2, elems=>[ ['str',{req=>1}], ['hash',{req=>1}] ]}], | ||
| 24 | ]}]; | ||
| 25 | |||
| 26 | 84 | requires 'handle_type'; | |
| 27 | |||
| 28 | 84 | has_clause 'v', | |
| 29 | v => 2, | ||
| 30 | prio => 0, | ||
| 31 | tags => ['meta', 'defhash'], | ||
| 32 | schema => ['float'=>{req=>1, is=>1}], | ||
| 33 | ; | ||
| 34 | |||
| 35 | 84 | has_clause 'defhash_v', | |
| 36 | v => 2, | ||
| 37 | prio => 0, | ||
| 38 | tags => ['meta', 'defhash'], | ||
| 39 | schema => ['float'=>{req=>1, is=>1}], | ||
| 40 | ; | ||
| 41 | |||
| 42 | 84 | has_clause 'schema_v', | |
| 43 | v => 2, | ||
| 44 | prio => 0, | ||
| 45 | tags => ['meta'], | ||
| 46 | schema => ['float'=>{req=>1}], | ||
| 47 | ; | ||
| 48 | |||
| 49 | 84 | has_clause 'base_v', | |
| 50 | v => 2, | ||
| 51 | prio => 0, | ||
| 52 | tags => ['meta'], | ||
| 53 | schema => ['float'=>{req=>1}], | ||
| 54 | ; | ||
| 55 | |||
| 56 | 84 | has_clause 'ok', | |
| 57 | v => 2, | ||
| 58 | tags => ['constraint'], | ||
| 59 | prio => 1, | ||
| 60 | schema => ['any', {}], | ||
| 61 | allow_expr => 1, | ||
| 62 | ; | ||
| 63 | 84 | has_clause 'default', | |
| 64 | v => 2, | ||
| 65 | prio => 1, | ||
| 66 | tags => ['default'], | ||
| 67 | schema => ['any', {}], | ||
| 68 | allow_expr => 1, | ||
| 69 | attrs => { | ||
| 70 | temp => { | ||
| 71 | schema => [bool => {default=>0}], | ||
| 72 | allow_expr => 0, | ||
| 73 | }, | ||
| 74 | }, | ||
| 75 | ; | ||
| 76 | 84 | has_clause 'prefilters', | |
| 77 | v => 2, | ||
| 78 | tags => ['filter'], | ||
| 79 | prio => 10, | ||
| 80 | schema => ['array' => {of=>$sch_filter_elem}], | ||
| 81 | attrs => { | ||
| 82 | temp => { | ||
| 83 | }, | ||
| 84 | } | ||
| 85 | ; | ||
| 86 | 84 | has_clause 'default_lang', | |
| 87 | v => 2, | ||
| 88 | tags => ['meta', 'defhash'], | ||
| 89 | prio => 2, | ||
| 90 | schema => ['str'=>{req=>1, default=>'en_US'}], | ||
| 91 | ; | ||
| 92 | 84 | has_clause 'name', | |
| 93 | v => 2, | ||
| 94 | tags => ['meta', 'defhash'], | ||
| 95 | prio => 2, | ||
| 96 | schema => ['str', {req=>1}], | ||
| 97 | ; | ||
| 98 | 84 | has_clause 'summary', | |
| 99 | v => 2, | ||
| 100 | prio => 2, | ||
| 101 | tags => ['meta', 'defhash'], | ||
| 102 | schema => ['str', {req=>1}], | ||
| 103 | ; | ||
| 104 | 84 | has_clause 'description', | |
| 105 | v => 2, | ||
| 106 | tags => ['meta', 'defhash'], | ||
| 107 | prio => 2, | ||
| 108 | schema => ['str', {req=>1}], | ||
| 109 | ; | ||
| 110 | 84 | has_clause 'tags', | |
| 111 | v => 2, | ||
| 112 | tags => ['meta', 'defhash'], | ||
| 113 | prio => 2, | ||
| 114 | schema => ['array', {of=>['str', {req=>1}, {}]}], | ||
| 115 | ; | ||
| 116 | 84 | has_clause 'req', | |
| 117 | v => 2, | ||
| 118 | tags => ['constraint'], | ||
| 119 | prio => 3, | ||
| 120 | schema => ['bool', {}], | ||
| 121 | allow_expr => 1, | ||
| 122 | ; | ||
| 123 | 84 | has_clause 'forbidden', | |
| 124 | v => 2, | ||
| 125 | tags => ['constraint'], | ||
| 126 | prio => 3, | ||
| 127 | schema => ['bool', {}], | ||
| 128 | allow_expr => 1, | ||
| 129 | ; | ||
| 130 | 84 | has_clause 'if', | |
| 131 | v => 2, | ||
| 132 | tags => ['constraint'], | ||
| 133 | prio => 50, | ||
| 134 | schema => ['array', {}], # XXX elems: [str|array|hash, str|array|hash, [ str|array|hash ]] | ||
| 135 | allow_expr => 0, | ||
| 136 | ; | ||
| 137 | |||
| 138 | #has_clause 'each', tags=>['constraint']; | ||
| 139 | |||
| 140 | #has_clause 'check_each', tags=>['constraint']; | ||
| 141 | |||
| 142 | #has_clause 'exists', tags=>['constraint']; | ||
| 143 | |||
| 144 | #has_clause 'check_exists', tags=>['constraint']; | ||
| 145 | |||
| 146 | #has_clause 'check', schema=>['sah::expr',{req=>1},{}], tags=>['constraint']; | ||
| 147 | |||
| 148 | 84 | has_clause 'clause', | |
| 149 | v => 2, | ||
| 150 | tags => ['constraint'], | ||
| 151 | prio => 50, | ||
| 152 | schema => ['array' => {req=>1, len=>2, elems => [ | ||
| 153 | ['sah::clname', {req=>1}], | ||
| 154 | ['any', {}], | ||
| 155 | ]}], | ||
| 156 | ; | ||
| 157 | 84 | has_clause 'clset', | |
| 158 | v => 2, | ||
| 159 | prio => 50, | ||
| 160 | tags => ['constraint'], | ||
| 161 | schema => ['sah::clset', {req=>1}], | ||
| 162 | ; | ||
| 163 | 84 | has_clause 'postfilters', | |
| 164 | v => 2, | ||
| 165 | tags => ['filter'], | ||
| 166 | prio => 90, | ||
| 167 | schema => ['array' => {req=>1, of=>$sch_filter_elem}], | ||
| 168 | attrs => { | ||
| 169 | } | ||
| 170 | ; | ||
| 171 | 84 | has_clause 'examples', | |
| 172 | v => 2, | ||
| 173 | tags => ['meta'], | ||
| 174 | prio => 99, | ||
| 175 | schema => ['array', {of=>['any', {}]}], # XXX non-hash or defhash with 'value' property specified | ||
| 176 | ; | ||
| 177 | 84 | has_clause 'links', | |
| 178 | v => 2, | ||
| 179 | tags => ['meta'], | ||
| 180 | prio => 99, | ||
| 181 | schema => ['array', {of=>['hash', {}]}], # XXX defhash, with at leasts 'url' property specified | ||
| 182 | ; | ||
| 183 | |||
| 184 | 84 | 1; | |
| 185 | # ABSTRACT: Base type | ||
| 186 | |||
| 187 | __END__ | ||