One-card tarot readings pass validation; free-tools row fits on phones
- The answer check wanted two items in every list, so the one-card daily reading always failed ($.cards: too few items). Two items are now asked only of string lists; other lists must not be empty. - The visitors' header row (Ingyenes · Születési horoszkóp · Csillagjegyek) overflowed and scrolled sideways below 412 px; it fits down to 320 px. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012vLHzh5qUhFtmJhzkcTbXL
This commit is contained in:
@@ -601,7 +601,7 @@ pub fn build(kind: Kind, language: &str, chart_text: &str, system: Option<&str>)
|
||||
|
||||
/// Checks an answer against our schema subset (objects with required
|
||||
/// properties, strings with at least three letters, string arrays with at
|
||||
/// least two items). A placeholder such as "x" counts as missing.
|
||||
/// least two items, other arrays not empty). A placeholder such as "x" counts as missing.
|
||||
pub fn validate(schema: &Value, value: &Value) -> Result<(), String> {
|
||||
fn walk(schema: &Value, value: &Value, path: &str) -> Result<(), String> {
|
||||
match schema["type"].as_str() {
|
||||
@@ -615,7 +615,9 @@ pub fn validate(schema: &Value, value: &Value) -> Result<(), String> {
|
||||
}
|
||||
Some("array") => {
|
||||
let items = value.as_array().ok_or_else(|| format!("{path}: expected an array"))?;
|
||||
if items.len() < 2 {
|
||||
// Lists of strings need two items; other lists (a one-card reading's cards) one.
|
||||
let min = if schema["items"]["type"] == "string" { 2 } else { 1 };
|
||||
if items.len() < min {
|
||||
return Err(format!("{path}: too few items"));
|
||||
}
|
||||
items.iter().enumerate().try_for_each(|(i, v)| walk(&schema["items"], v, &format!("{path}[{i}]")))
|
||||
|
||||
Reference in New Issue
Block a user