Slide 1

Slide 1 text

Validations in Oracle Apex Help your users provide meaningful data a presentation by

Slide 2

Slide 2 text

Who am I? • Independent Consultant since 2012 • smart4apex founding member (2010) • Oracle since 2002 (Oracle 8i) • PL/SQL, Apex, HTML(5), CSS(3), JavaScript, XML, XSLT • Special interest in UI • Trainer at skillbuilders.com • RIMA on Oracle Forums @rhjmartens richardmartens.blogspot.nl Richard Martens

Slide 3

Slide 3 text

Who is Smart4apex Reliable Apex solutions by shared knowledge

Slide 4

Slide 4 text

Why this presentation ? • System security • Prevent SQL injection • Improve data quality • Help your users • Applications should be usable without reading documentation 4

Slide 5

Slide 5 text

Agenda • Apex Validations • Database constraints – Using the Error Handling Function • Client side validation – HTML5 validations – Using a JavaScript library

Slide 6

Slide 6 text

Apex Validations • 23 !! Different options for validations – SQL • (no) Rows • Expression – PL/SQL • Expression • Error • Function body (Boolean / error-text) – Item comparison • (not) Null or zero • (not) Contains something • IS (not) a value • Regular Expression – Validations pass when the validation is “true” 6 MOSTLY used

Slide 7

Slide 7 text

Apex Validations Regular validations • reference item using :BIND notation for page item • page vs item validations Tabular Form validations • reference column using :BIND notation for column or pageitem • row vs column validations 7

Slide 8

Slide 8 text

Database constraints • Using real constraints – Table constraints – Column constraints (not null) – Advantage: easy to maintain at table definition – Disadvantage: cannot use your own code • Using triggers – Advantage: • Can use PLSQL code • Before / After / Statement triggers – Disadvantages • Not as easy to maintain • Error handling function cannot focus on element by default (must write specific plsql code) • Use apex’s “Error handling function” to get meaningful error messages 8

Slide 9

Slide 9 text

The Error Handling Function • Set at application definition • Map ORA messages to meaningful messages • When check constraint, the element automatically gets selected in the form • Can utilize error messages thrown by triggers (no automatic element-selection) 9

Slide 10

Slide 10 text

Client side validation • HTML(5) / CSS(3) • Dynamic Actions • JavaScript: – www.w3schools.com/js/js_validation.asp – Validate.js framework • Setup using JavaScript – Parseley framework • Setup using field attributes 10

Slide 11

Slide 11 text

HTML5 / CSS3 validations • Built-in into HTML • Specific rendering of keyboard on mobile devices – http://html5doctor.com/html5-forms-input-types/ • Apex does not support all types – only text, email, phone-number and url – other types by using a dynamic action to overwrite the “type” attribute • Uses elements attributes – type • color / date / datetime / datetime-local / email / month / number / range / search / tel / time / url / week – autocomplete – formnovalidate – list – min and max – multiple (email / file) – pattern (regexp) – placeholder – required – step – autocomplete – novalidate 11

Slide 12

Slide 12 text

HTML5 / CSS3 validations • Facts & Features – con: not enforcing • But you can write JavaScript for that – pro: built into the browser, no installation required and backwards compatible – pro: can use CSS to style element 12

Slide 13

Slide 13 text

Javascript frameworks • validatious.org(stand-alone) – http://validatious.org (site seems to be offline a lot) • validate.js(stand-alone) – http://rickharrison.github.io/validate.js/ • jqueryvalidation.org(jQuery) – http://jqueryvalidation.org/rules • valid8 (jQuery) – http://unwrongest.com/projects/valid8/ • GentleForm – https://github.com/Zhouzi/GentleForm • parsley – http://parsleyjs.org. . . 13

Slide 14

Slide 14 text

Parsley • Uses element attributes • HTML5 compliant • Can prevent submit when set on form level • http://parsleyjs.org/ • Validators – required – type=“email”/”url” – data-parsley-type=“number” – data-parsley-type=“integer” – data-parsley-type=“digits” – data-parsley-minlegth=“5” – data-parsley-maxlength=“5” – data-parsley-length=“[5, 10]” – data-parsley-equalto="#anotherfield” – … 14

Slide 15

Slide 15 text

Helpfull URLs • https://developer.mozilla.org/en- US/docs/Web/Guide/HTML/Forms/Data_form_validation#Example_that_doesn't_use_the_constraint_validation_API • https://www.smashingmagazine.com/2009/07/web-form-validation-best-practices-and-tutorials/ • http://sixrevisions.com/user-interface/best-practices-for-hints-and-validation-in-web-forms/ • http://www.alistapart.com/articles/inline-validation-in-web-forms/ 15

Slide 16

Slide 16 text

Questions ?

Slide 17

Slide 17 text

No content