Module: Phlex::Validator::HTML::Mixin

Defined in:
lib/phlex/validator/html/mixin.rb

Instance Method Summary collapse

Instance Method Details

#__validate__(attributes, schema) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/phlex/validator/html/mixin.rb', line 5

def __validate__(attributes, schema)
	attributes.each do |k, v|
		# All attributes are nilable
		next if nil === v

		# Ignore string keys as an escape hatch
		next if String === k

		# If the key is not a String, it must be a Symbol
		raise ArgumentError unless Symbol === k

		Literal.check(
			expected: schema[k] || Attributes::Global[k] || Attribute,
			actual: v
		)
	end
end

#a(**attributes) ⇒ Object



23
24
25
26
# File 'lib/phlex/validator/html/mixin.rb', line 23

def a(**attributes)
	__validate__(attributes, Attributes::A)
	super
end

#abbr(**attributes) ⇒ Object



28
29
30
31
# File 'lib/phlex/validator/html/mixin.rb', line 28

def abbr(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#address(**attributes) ⇒ Object



33
34
35
36
# File 'lib/phlex/validator/html/mixin.rb', line 33

def address(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#area(**attributes) ⇒ Object



38
39
40
41
# File 'lib/phlex/validator/html/mixin.rb', line 38

def area(**attributes)
	__validate__(attributes, Attributes::Area)
	super
end

#article(**attributes) ⇒ Object



43
44
45
46
# File 'lib/phlex/validator/html/mixin.rb', line 43

def article(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#aside(**attributes) ⇒ Object



48
49
50
51
# File 'lib/phlex/validator/html/mixin.rb', line 48

def aside(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#audio(**attributes) ⇒ Object



53
54
55
56
# File 'lib/phlex/validator/html/mixin.rb', line 53

def audio(**attributes)
	__validate__(attributes, Attributes::Audio)
	super
end

#b(**attributes) ⇒ Object



58
59
60
61
# File 'lib/phlex/validator/html/mixin.rb', line 58

def b(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#base(**attributes) ⇒ Object

TODO: We should validate that this comes before other link like tags TODO: We should ensure at least one of ‘href` or `target` are set



65
66
67
68
# File 'lib/phlex/validator/html/mixin.rb', line 65

def base(**attributes)
	__validate__(attributes, Attributes::Base)
	super
end

#bdi(**attributes) ⇒ Object



70
71
72
73
# File 'lib/phlex/validator/html/mixin.rb', line 70

def bdi(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#bdo(**attributes) ⇒ Object



75
76
77
78
# File 'lib/phlex/validator/html/mixin.rb', line 75

def bdo(**attributes)
	__validate__(attributes, Attributes::Bdo)
	super
end

#blockquote(**attributes) ⇒ Object



80
81
82
83
# File 'lib/phlex/validator/html/mixin.rb', line 80

def blockquote(**attributes)
	__validate__(attributes, Attributes::Blockquote)
	super
end

#body(**attributes) ⇒ Object



85
86
87
88
# File 'lib/phlex/validator/html/mixin.rb', line 85

def body(**attributes)
	__validate__(attributes, Attributes::Body)
	super
end

#br(**attributes) ⇒ Object



90
91
92
93
# File 'lib/phlex/validator/html/mixin.rb', line 90

def br(**attributes)
	__validate__(attributes, Attributes::Br)
	super
end

#button(**attributes) ⇒ Object



95
96
97
98
# File 'lib/phlex/validator/html/mixin.rb', line 95

def button(**attributes)
	__validate__(attributes, Attributes::Button)
	super
end

#caption(**attributes) ⇒ Object



100
101
102
103
# File 'lib/phlex/validator/html/mixin.rb', line 100

def caption(**attributes)
	__validate__(attributes, Attributes::Caption)
	super
end

#cite(**attributes) ⇒ Object



105
106
107
108
# File 'lib/phlex/validator/html/mixin.rb', line 105

def cite(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#code(**attributes) ⇒ Object



110
111
112
113
# File 'lib/phlex/validator/html/mixin.rb', line 110

def code(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#col(**attributes) ⇒ Object



115
116
117
118
# File 'lib/phlex/validator/html/mixin.rb', line 115

def col(**attributes)
	__validate__(attributes, Attributes::Col)
	super
end

#colgroup(**attributes) ⇒ Object



120
121
122
123
# File 'lib/phlex/validator/html/mixin.rb', line 120

def colgroup(**attributes)
	__validate__(attributes, Attributes::Col)
	super
end

#data(**attributes) ⇒ Object



125
126
127
128
# File 'lib/phlex/validator/html/mixin.rb', line 125

def data(**attributes)
	__validate__(attributes, Attributes::Data)
	super
end

#datalist(**attributes) ⇒ Object



130
131
132
133
# File 'lib/phlex/validator/html/mixin.rb', line 130

def datalist(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#dd(**attributes) ⇒ Object



135
136
137
138
# File 'lib/phlex/validator/html/mixin.rb', line 135

def dd(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#del(**attributes) ⇒ Object



140
141
142
143
# File 'lib/phlex/validator/html/mixin.rb', line 140

def del(**attributes)
	__validate__(attributes, Attributes::Del)
	super
end

#details(**attributes) ⇒ Object



145
146
147
148
# File 'lib/phlex/validator/html/mixin.rb', line 145

def details(**attributes)
	__validate__(attributes, Attributes::Details)
	super
end

#dfn(**attributes) ⇒ Object



150
151
152
153
# File 'lib/phlex/validator/html/mixin.rb', line 150

def dfn(**attributes)
	__validate__(attributes, Attributes::Dfn)
	super
end

#dialog(**attributes) ⇒ Object



155
156
157
158
# File 'lib/phlex/validator/html/mixin.rb', line 155

def dialog(**attributes)
	__validate__(attributes, Attributes::Dialog)
	super
end

#div(**attributes) ⇒ Object



160
161
162
163
# File 'lib/phlex/validator/html/mixin.rb', line 160

def div(**attributes)
	__validate__(attributes, Attributes::Div)
	super
end

#dl(**attributes) ⇒ Object



165
166
167
168
# File 'lib/phlex/validator/html/mixin.rb', line 165

def dl(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#dt(**attributes) ⇒ Object



170
171
172
173
# File 'lib/phlex/validator/html/mixin.rb', line 170

def dt(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#em(**attributes) ⇒ Object



175
176
177
178
# File 'lib/phlex/validator/html/mixin.rb', line 175

def em(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#embed(**attributes) ⇒ Object



180
181
182
183
# File 'lib/phlex/validator/html/mixin.rb', line 180

def embed(**attributes)
	__validate__(attributes, Attributes::Embed)
	super
end

#fencedframe(**attributes) ⇒ Object



185
186
187
188
# File 'lib/phlex/validator/html/mixin.rb', line 185

def fencedframe(**attributes)
	__validate__(attributes, Attributes::Fencedframe)
	super
end

#fieldset(**attributes) ⇒ Object



190
191
192
193
# File 'lib/phlex/validator/html/mixin.rb', line 190

def fieldset(**attributes)
	__validate__(attributes, Attributes::Fieldset)
	super
end

#figcaption(**attributes) ⇒ Object



195
196
197
198
# File 'lib/phlex/validator/html/mixin.rb', line 195

def figcaption(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#figure(**attributes) ⇒ Object



200
201
202
203
# File 'lib/phlex/validator/html/mixin.rb', line 200

def figure(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end


205
206
207
208
# File 'lib/phlex/validator/html/mixin.rb', line 205

def footer(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#form(**attributes) ⇒ Object



210
211
212
213
# File 'lib/phlex/validator/html/mixin.rb', line 210

def form(**attributes)
	__validate__(attributes, Attributes::Form)
	super
end

#h1(**attributes) ⇒ Object



215
216
217
218
# File 'lib/phlex/validator/html/mixin.rb', line 215

def h1(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#h2(**attributes) ⇒ Object



220
221
222
223
# File 'lib/phlex/validator/html/mixin.rb', line 220

def h2(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#h3(**attributes) ⇒ Object



225
226
227
228
# File 'lib/phlex/validator/html/mixin.rb', line 225

def h3(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#h4(**attributes) ⇒ Object



230
231
232
233
# File 'lib/phlex/validator/html/mixin.rb', line 230

def h4(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#h5(**attributes) ⇒ Object



235
236
237
238
# File 'lib/phlex/validator/html/mixin.rb', line 235

def h5(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#h6(**attributes) ⇒ Object



240
241
242
243
# File 'lib/phlex/validator/html/mixin.rb', line 240

def h6(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#head(**attributes) ⇒ Object



245
246
247
248
# File 'lib/phlex/validator/html/mixin.rb', line 245

def head(**attributes)
	__validate__(attributes, Attributes::Head)
	super
end

#header(**attributes) ⇒ Object



250
251
252
253
# File 'lib/phlex/validator/html/mixin.rb', line 250

def header(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#hgroup(**attributes) ⇒ Object



255
256
257
258
# File 'lib/phlex/validator/html/mixin.rb', line 255

def hgroup(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#hr(**attributes) ⇒ Object



260
261
262
263
# File 'lib/phlex/validator/html/mixin.rb', line 260

def hr(**attributes)
	__validate__(attributes, Attributes::Hr)
	super
end

#html(**attributes) ⇒ Object



265
266
267
268
# File 'lib/phlex/validator/html/mixin.rb', line 265

def html(**attributes)
	__validate__(attributes, Attribute::HTML)
	super
end

#i(**attributes) ⇒ Object



270
271
272
273
# File 'lib/phlex/validator/html/mixin.rb', line 270

def i(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#iframe(**attributes) ⇒ Object



275
276
277
278
# File 'lib/phlex/validator/html/mixin.rb', line 275

def iframe(**attributes)
	__validate__(attributes, Attributes::Iframe)
	super
end

#img(**attributes) ⇒ Object



280
281
282
283
# File 'lib/phlex/validator/html/mixin.rb', line 280

def img(**attributes)
	__validate__(attributes, Attributes::Img)
	super
end

#input(type:, name:, **attributes) ⇒ Object



285
286
287
288
289
290
291
# File 'lib/phlex/validator/html/mixin.rb', line 285

def input(type:, name:, **attributes)
	# TODO: handle non existing type
	type = type.tr("-", "_").to_sym if String === type

	__validate__({ type:, name:, **attributes }, Attributes::Input[type])
	super
end

#ins(**attributes) ⇒ Object



293
294
295
296
# File 'lib/phlex/validator/html/mixin.rb', line 293

def ins(**attributes)
	__validate__(attributes, Attributes::Ins)
	super
end

#kbd(**attributes) ⇒ Object



298
299
300
301
# File 'lib/phlex/validator/html/mixin.rb', line 298

def kbd(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#label(**attributes) ⇒ Object



303
304
305
306
# File 'lib/phlex/validator/html/mixin.rb', line 303

def label(**attributes)
	__validate__(attributes, Attributes::Label)
	super
end

#legend(**attributes) ⇒ Object



308
309
310
311
# File 'lib/phlex/validator/html/mixin.rb', line 308

def legend(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#li(**attributes) ⇒ Object



313
314
315
316
# File 'lib/phlex/validator/html/mixin.rb', line 313

def li(**attributes)
	__validate__(attributes, Attributes::Li)
	super
end


318
319
320
321
# File 'lib/phlex/validator/html/mixin.rb', line 318

def link(**attributes)
	__validate__(attributes, Attributes::Link)
	super
end

#main(**attributes) ⇒ Object



323
324
325
326
# File 'lib/phlex/validator/html/mixin.rb', line 323

def main(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#map(**attributes) ⇒ Object



328
329
330
331
# File 'lib/phlex/validator/html/mixin.rb', line 328

def map(**attributes)
	__validate__(attributes, Attributes::Map)
	super
end

#mark(**attributes) ⇒ Object



333
334
335
336
# File 'lib/phlex/validator/html/mixin.rb', line 333

def mark(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end


338
339
340
341
# File 'lib/phlex/validator/html/mixin.rb', line 338

def menu(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#meta(**attributes) ⇒ Object



343
344
345
346
# File 'lib/phlex/validator/html/mixin.rb', line 343

def meta(**attributes)
	__validate__(attributes, Attributes::Meta)
	super
end

#meter(**attributes) ⇒ Object



348
349
350
351
# File 'lib/phlex/validator/html/mixin.rb', line 348

def meter(**attributes)
	__validate__(attributes, Attributes::Meter)
	super
end


353
354
355
356
# File 'lib/phlex/validator/html/mixin.rb', line 353

def nav(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#noscript(**attributes) ⇒ Object



358
359
360
361
# File 'lib/phlex/validator/html/mixin.rb', line 358

def noscript(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#object(**attributes) ⇒ Object



363
364
365
366
# File 'lib/phlex/validator/html/mixin.rb', line 363

def object(**attributes)
	__validate__(attributes, Attributes::Object)
	super
end

#ol(**attributes) ⇒ Object



368
369
370
371
# File 'lib/phlex/validator/html/mixin.rb', line 368

def ol(**attributes)
	__validate__(attributes, Attributes::Ol)
	super
end

#optgroup(**attributes) ⇒ Object



373
374
375
376
# File 'lib/phlex/validator/html/mixin.rb', line 373

def optgroup(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#output(**attributes) ⇒ Object



378
379
380
381
# File 'lib/phlex/validator/html/mixin.rb', line 378

def output(**attributes)
	__validate__(attributes, Attributes::Output)
	super
end

#p(**attributes) ⇒ Object



383
384
385
386
# File 'lib/phlex/validator/html/mixin.rb', line 383

def p(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#picture(**attributes) ⇒ Object



388
389
390
391
# File 'lib/phlex/validator/html/mixin.rb', line 388

def picture(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#pre(**attributes) ⇒ Object



393
394
395
# File 'lib/phlex/validator/html/mixin.rb', line 393

def pre(**attributes)
	__validate__(attributes, Attributes::Pre)
end

#progress(**attributes) ⇒ Object



397
398
399
400
# File 'lib/phlex/validator/html/mixin.rb', line 397

def progress(**attributes)
	__validate__(attributes, Attributes::Progress)
	super
end

#q(**attributes) ⇒ Object



402
403
404
405
# File 'lib/phlex/validator/html/mixin.rb', line 402

def q(**attributes)
	__validate__(attributes, Attributes::Q)
	super
end

#rp(**attributes) ⇒ Object



407
408
409
410
# File 'lib/phlex/validator/html/mixin.rb', line 407

def rp(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#rt(**attributes) ⇒ Object



412
413
414
415
# File 'lib/phlex/validator/html/mixin.rb', line 412

def rt(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#ruby(**attributes) ⇒ Object



417
418
419
420
# File 'lib/phlex/validator/html/mixin.rb', line 417

def ruby(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#s(**attributes) ⇒ Object



422
423
424
425
# File 'lib/phlex/validator/html/mixin.rb', line 422

def s(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#samp(**attributes) ⇒ Object



427
428
429
430
# File 'lib/phlex/validator/html/mixin.rb', line 427

def samp(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#script(**attributes) ⇒ Object



432
433
434
435
# File 'lib/phlex/validator/html/mixin.rb', line 432

def script(**attributes)
	__validate__(attributes, Attributes::Script)
	super
end

#search(**attributes) ⇒ Object



437
438
439
# File 'lib/phlex/validator/html/mixin.rb', line 437

def search(**attributes)
	__validate__(attributes, Attributes::Global)
end

#section(**attributes) ⇒ Object



441
442
443
444
# File 'lib/phlex/validator/html/mixin.rb', line 441

def section(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#select(**attributes) ⇒ Object



446
447
448
449
# File 'lib/phlex/validator/html/mixin.rb', line 446

def select(**attributes)
	__validate__(attributes, Attributes::Select)
	super
end

#slot(**attributes) ⇒ Object



451
452
453
454
# File 'lib/phlex/validator/html/mixin.rb', line 451

def slot(**attributes)
	__validate__(attributes, Attributes::Slot)
	super
end

#small(**attributes) ⇒ Object



456
457
458
459
# File 'lib/phlex/validator/html/mixin.rb', line 456

def small(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#source(**attributes) ⇒ Object



461
462
463
464
# File 'lib/phlex/validator/html/mixin.rb', line 461

def source(**attributes)
	__validate__(attributes, Attributes::Source)
	super
end

#span(**attributes) ⇒ Object



466
467
468
469
# File 'lib/phlex/validator/html/mixin.rb', line 466

def span(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#strong(**attributes) ⇒ Object



471
472
473
474
# File 'lib/phlex/validator/html/mixin.rb', line 471

def strong(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#style(**attributes) ⇒ Object



476
477
478
479
# File 'lib/phlex/validator/html/mixin.rb', line 476

def style(**attributes)
	__validate__(attributes, Attributes::Style)
	super
end

#sub(**attributes) ⇒ Object



481
482
483
484
# File 'lib/phlex/validator/html/mixin.rb', line 481

def sub(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#summary(**attributes) ⇒ Object



486
487
488
489
# File 'lib/phlex/validator/html/mixin.rb', line 486

def summary(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#sup(**attributes) ⇒ Object



491
492
493
494
# File 'lib/phlex/validator/html/mixin.rb', line 491

def sup(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#table(**attributes) ⇒ Object



496
497
498
499
# File 'lib/phlex/validator/html/mixin.rb', line 496

def table(**attributes)
	__validate__(attributes, Attributes::Table)
	super
end

#tbody(**attributes) ⇒ Object



501
502
503
504
# File 'lib/phlex/validator/html/mixin.rb', line 501

def tbody(**attributes)
	__validate__(attributes, Attributes::Tbody)
	super
end

#td(**attributes) ⇒ Object



506
507
508
509
# File 'lib/phlex/validator/html/mixin.rb', line 506

def td(**attributes)
	__validate__(attributes, Attributes::Td)
	super
end

#template(**attributes) ⇒ Object



511
512
513
514
# File 'lib/phlex/validator/html/mixin.rb', line 511

def template(**attributes)
	__validate__(attributes, Attributes::Template)
	super
end

#textarea(**attributes) ⇒ Object



516
517
518
519
# File 'lib/phlex/validator/html/mixin.rb', line 516

def textarea(**attributes)
	__validate__(attributes, Attributes::Textarea)
	super
end

#tfoot(**attributes) ⇒ Object



521
522
523
524
# File 'lib/phlex/validator/html/mixin.rb', line 521

def tfoot(**attributes)
	__validate__(attributes, Attributes::Tfoot)
	super
end

#th(**attributes) ⇒ Object



526
527
528
529
# File 'lib/phlex/validator/html/mixin.rb', line 526

def th(**attributes)
	__validate__(attributes, Attributes::Th)
	super
end

#thead(**attributes) ⇒ Object



531
532
533
534
# File 'lib/phlex/validator/html/mixin.rb', line 531

def thead(**attributes)
	__validate__(attributes, Attributes::Thead)
	super
end

#time(**attributes) ⇒ Object



536
537
538
539
# File 'lib/phlex/validator/html/mixin.rb', line 536

def time(**attributes)
	__validate__(attributes, Attributes::Time)
	super
end

#title(**attributes) ⇒ Object



541
542
543
544
# File 'lib/phlex/validator/html/mixin.rb', line 541

def title(**attributes)
	__validate__(attributes, Attributes::Title)
	super
end

#tr(**attributes) ⇒ Object



546
547
548
549
# File 'lib/phlex/validator/html/mixin.rb', line 546

def tr(**attributes)
	__validate__(attributes, Attributes::Tr)
	super
end

#track(**attributes) ⇒ Object



551
552
553
554
# File 'lib/phlex/validator/html/mixin.rb', line 551

def track(**attributes)
	__validate__(attributes, Attributes::Track)
	super
end

#tt(**attributes) ⇒ Object



556
557
558
559
# File 'lib/phlex/validator/html/mixin.rb', line 556

def tt(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#u(**attributes) ⇒ Object



561
562
563
564
# File 'lib/phlex/validator/html/mixin.rb', line 561

def u(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#ul(**attributes) ⇒ Object



566
567
568
569
# File 'lib/phlex/validator/html/mixin.rb', line 566

def ul(**attributes)
	__validate__(attributes, Attributes::Ul)
	super
end

#var(**attributes) ⇒ Object



571
572
573
574
# File 'lib/phlex/validator/html/mixin.rb', line 571

def var(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end

#video(**attributes) ⇒ Object



576
577
578
579
# File 'lib/phlex/validator/html/mixin.rb', line 576

def video(**attributes)
	__validate__(attributes, Attributes::Video)
	super
end

#wbr(**attributes) ⇒ Object



581
582
583
584
# File 'lib/phlex/validator/html/mixin.rb', line 581

def wbr(**attributes)
	__validate__(attributes, Attributes::Global)
	super
end