Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 1 addition & 80 deletions docs/labs/input1.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
<link rel="stylesheet" href="checker.css">
<script src="js-yaml.min.js"></script>
<script src="checker.js"></script>
<script src="input1.js"></script>
<link rel="license" href="https://creativecommons.org/licenses/by/4.0/">

<!-- See create_labs.md for how to create your own lab! -->
Expand All @@ -22,86 +23,6 @@
isInt \( \{ min: 1 , max: 9_?999 ,? \} \) , \s*
</script>

<script id="info" type="application/yaml">
---
hints:
- absent: ", $"
text: This is a parameter, it must end with a comma.
examples:
- - " "
- absent: query \( ["'`]id["'`] \)
text: Add query("id") to verify its value.
examples:
- - ","
- - " query(),"
- present: query \( ["'`]id["'`] \) [^. ]
text: After query("id") use a period to invoke a verification method.
examples:
- - " query('id'),"
- present: "(isint|Isint|IsInt|ISINT)"
text: JavaScript is case-sensitive. Use isInt instead of the case you have.
examples:
- - " query('id').isint(),"
- - " query('id').IsInt(),"
- absent: isInt
text: Use isInt to determine if the parameter is an integer.
examples:
- - " query('id').,"
- present: ' query \( ["''`]id["''`] \).*\([^)]*$'
text: After query("id") you have an ( but there's no matching ).
examples:
- - " query('id').isInt(,"
- absent: isInt \(.*\)
text: isInt should be followed by (...).
examples:
- - " query('id').isInt,"
- present: "\\{[^}]*$"
text: You have started an object using { but there's no matching }.
examples:
- - " query('id').isInt({),"
- absent: isInt \( \{.*\} \)
text: Inside the parenthesis of isInt() you should have an object like {...}.
examples:
- - " query('id').isInt(),"
- absent: min
text: 'Use min: to specify a minimum value.'
examples:
- - " query('id').isInt({}),"
- absent: max
text: 'Use max: to specify a minimum value.'
examples:
- - " query('id').isInt({min: 1}),"
- present: max.*min
text: JavaScript allows hash entries to be in any order,
but this can be confusing to humans. Conventionally minimum values
are given before maximum values; please follow that convention.
examples:
- - " query('id').isInt({max: 9999, min: 1}),"
successes:
- - " query ( 'id' ) . isInt ( {min: 1 , max: 9999 } ) ,"
- - " query ( `id` ) . isInt ( {min: 1 , max: 9_999 } ) , "
- - 'query ( "id" ) . isInt ( {min: 1 , max: 9_999 } ) ,'
failures:
- - " query,"
- - 'query(''id'').isint({min: 1, max: 9999})'
- - 'query(''id'').isInt({min: 1, max: 9999})'
# ADVANCED use - define our own preprocessing commands.
# I suggest using "|-" (stripping the trailing newlines)
# preprocessing:
# -
# - |-
# [\n\r]+
# - ""
# -
# - |-
# (\\s\*)?\s+(\\s\*)?
# - "\\s*"
# debug: true
</script>
<!--

-->

</head>
<body>
<!-- For GitHub Pages formatting: -->
Expand Down
101 changes: 101 additions & 0 deletions docs/labs/input1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
info =
{
hints: [
{
absent: ", $",
text: "This is a parameter, it must end with a comma.",
"examples": [
[ " " ]
]
},
{
absent: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \)`,
text: "Add query(\"id\") to verify its value.",
"examples": [
[ "," ],
[ " query()," ]
]
},
{
present: String.raw`query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \) [^. ]`,
text: "After query(\"id\") use a period to invoke a verification method.",
"examples": [
[ " query('id')," ]
]
},
{
present: "(isint|Isint|IsInt|ISINT)",
text: "JavaScript is case-sensitive. Use isInt instead of the case you have.",
"examples": [
[ " query('id').isint()," ],
[ " query('id').IsInt()," ]
]
},
{
absent: "isInt",
text: "Use isInt to determine if the parameter is an integer.",
"examples": [
[ " query('id').," ]
]
},
{
present: String.raw` query \( ["'${BACKQUOTE}]id["'${BACKQUOTE}] \).*\([^)]*$`,
text: "After query(\"id\") you have an ( but there's no matching ).",
"examples": [
[ " query('id').isInt(," ]
]
},
{
absent: String.raw`isInt \(.*\)`,
text: "isInt should be followed by (...).",
"examples": [
[ " query('id').isInt," ]
]
},
{
present: String.raw`\{[^}]*$`,
text: "You have started an object using { but there's no matching }.",
"examples": [
[ " query('id').isInt({)," ]
]
},
{
absent: String.raw`isInt \( \{.*\} \)`,
text: "Inside the parenthesis of isInt() you should have an object like {...}.",
"examples": [
[ " query('id').isInt()," ]
]
},
{
absent: "min",
text: "Use min: to specify a minimum value.",
"examples": [
[ " query('id').isInt({})," ]
]
},
{
absent: "max",
text: "Use max: to specify a minimum value.",
"examples": [
[ " query('id').isInt({min: 1})," ]
]
},
{
present: "max.*min",
text: "JavaScript allows hash entries to be in any order, but this can be confusing to humans. Conventionally minimum values are given before maximum values; please follow that convention.",
"examples": [
[ " query('id').isInt({max: 9999, min: 1})," ]
]
}
],
successes: [
[ " query ( 'id' ) . isInt ( {min: 1 , max: 9999 } ) ," ],
[ " query ( `id` ) . isInt ( {min: 1 , max: 9_999 } ) , " ],
[ "query ( \"id\" ) . isInt ( {min: 1 , max: 9_999 } ) ," ]
],
failures: [
[ " query," ],
[ "query('id').isint({min: 1, max: 9999})" ],
[ "query('id').isInt({min: 1, max: 9999})" ]
]
}