diff --git a/docs/labs/input2.js b/docs/labs/input2.js index 1a7c5db1..c861d26c 100644 --- a/docs/labs/input2.js +++ b/docs/labs/input2.js @@ -3,55 +3,90 @@ info = hints: [ { absent: ", $", - text: "This is a parameter, it must end with a comma." + text: "This is a parameter, it must end with a comma.", + examples: [ + [ "" ], + [ " query('id')" ], + ], }, { absent: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \)`, - text: "Use query() with an 'id' parameter." + text: "Use query() with an 'id' parameter.", + examples: [ + [ " query()," ], + ], }, { present: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \) [^. ]`, - text: "After query(\"id\") use a period to invoke a verification method." + text: "After query(\"id\") use a period to invoke a verification method.", + examples: [ + [ " query('id')," ], + ], }, { present: "(islength|Islength|IsLength|ISLENGTH)", - text: "JavaScript is case-sensitive. Use isLength instead of the case you have." + text: "JavaScript is case-sensitive. Use isLength instead of the case you have.", + examples: [ + [ " query('id').IsLength({max: 80})," ], + ], }, { absent: "isLength", - text: "Use isLength()." + text: "Use isLength().", + examples: [ + [ " query('id').length({max: 80})," ], + ], }, { present: String.raw`isLength \( [a-z]`, - text: "You need to pass isLength() an object within {...}." + text: "You need to pass isLength() an object within {...}.", + examples: [ + [ " query('id').isLength(max: 80)," ], + ], }, { absent: "matches", - text: "Use matches()." + text: "Use matches().", + examples: [ + [ " query('id').isLength({max: 80})," ], + ], }, { present: String.raw`matches \( /[^^]`, - text: "Match the whole string - begin the regular expression with ^" + text: "Match the whole string - begin the regular expression with ^", + examples: [ + [ " query('id').isLength({max: 80}).matches(//)," ], + ], }, { present: String.raw`matches \( /[^$/]*[^$]/`, - text: "Match the whole string - end the regular expression with $" - }, - { - present: String.raw`matches \( /[^$/]*[^$]/`, - text: "Match the whole string - end the regular expression with $" + text: "Match the whole string - end the regular expression with $", + examples: [ + [ " query('id').isLength({max: 80}).matches(/^/)," ], + ], }, { present: String.raw`matches \( /\^\[A-Z\]-`, - text: "That would match only one letter before the dash, you need two." + text: "That would match only one letter before the dash, you need two.", + examples: [ + [ " query('id').isLength({max: 80}).matches(/^[A-Z]-\d+-\d+$/)," ], + ], }, { present: String.raw`matches \( /.*(\[0-9\]|\d)\*`, - text: "You need to match one or more digits; * allows 0 or more. A + would be better suited for this task." + text: "You need to match one or more digits; * allows 0 or more. A + would be better suited for this task.", + examples: [ + [ " query('id').isLength({max: 80}).matches(/^[A-Z]{2}-[0-9]*-\d*$/)," ], + ], }, { present: String.raw`\s*, , $`, - text: "You have two commas at the end. Use only one. You may need to scroll or increase the text area to see both of them." + text: "You have two commas at the end. Use only one. You may need to scroll or increase the text area to see both of them.", + examples: [ + [ + "query('id').isLength({max:80}).matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ), ,", + ], + ], }, ], expected: [ @@ -73,27 +108,27 @@ info = ], successes: [ [ - "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/)," + "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/),", ], [ - " query (`id`) . isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/ ) , " + " query (`id`) . isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/ ) , ", ], ], failures: [ [ - "query('id').isLength({max:80}).matches( /^[A-Z]{2}-[0-9]+- [0-9]+$/ )," + "query('id').isLength({max:80}).matches( /^[A-Z]{2}-[0-9]+- [0-9]+$/ ),", ], [ - "query('id').isLength().matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ )," + "query('id').isLength().matches( /^[A-Z]{2}-[0-9]+-[0-9]+$/ ),", ], [ - "query('id').isLength({max:80}).matches( /[A-Z]{2}-[0-9]+-[0-9]+/ )," + "query('id').isLength({max:80}).matches( /[A-Z]{2}-[0-9]+-[0-9]+/ ),", ], [ - "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/)" + "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}-\\d+-[0-9]+$/)", ], [ - "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}- \\d+-[0-9]+$/)," + "query(`id`).isLength( {max:80}).matches(/^[A-Z]{2}- \\d+-[0-9]+$/),", ], ], };