วิธีหนึ่งในการรับประกันคุณภาพข้อมูลคือการเพิ่ม constraint ให้กับฟิลด์ข้อมูลในแบบฟอร์มของคุณ Constraint ช่วยป้องกันผู้ใช้จากการป้อนคำตอบที่ไม่ถูกต้องหรือเป็นไปไม่ได้ ตัวอย่างเช่น เมื่อถามรายได้ของบุคคล คุณต้องการหลีกเลี่ยงค่าที่ไม่สมเหตุสมผล

  1. เพิ่มคอลัมน์ใหม่ชื่อ “constraint” ในแบบฟอร์มของคุณ
  2. ในคอลัมน์ “constraint” ป้อนสูตรที่ระบุขีดจำกัดของคำตอบ

ตัวอย่าง

ลองพิจารณาตัวอย่างที่เราต้องการเพิ่ม constraint สำหรับรายได้ของบุคคล constraint กำหนดให้รายได้อยู่ระหว่าง $0 ถึง $1,000,000:

nameconstraint
Income. >= 0 & . <= 1000000

Hard constraint

Hard constraint จะบล็อกการส่งแบบฟอร์มทั้งหมดหากค่าที่ป้อนไม่ตรงตามนิพจน์ ผู้เก็บข้อมูลไม่สามารถดำเนินการต่อได้จนกว่าจะป้อนค่าที่ถูกต้อง

typenamelabelconstraintconstraint_message
integerageAge of respondent. > 0 and . <= 120Age must be between 1 and 120
decimaltemperatureBody temperature (°C). >= 35 and . <= 42Temperature must be between 35°C and 42°C
textphonePhone numberregex(., '^[0-9]{10}$')Enter a 10-digit phone number

การใช้ regex() เพื่อตรวจสอบรูปแบบ

ฟังก์ชัน regex(value, pattern) ทดสอบค่ากับนิพจน์ปกติ:

typenamelabelconstraintconstraint_message
textemailEmail addressregex(., '^[^@]+@[^@]+\.[^@]+$')Enter a valid email address
textzip_codeZIP coderegex(., '^[0-9]{5}$')Enter a 5-digit ZIP code

Soft alert

Soft alert (หรือเรียกว่า soft constraint หรือคำเตือน) เตือนผู้เก็บข้อมูลว่าค่าดูผิดปกติ แต่ยังคงอนุญาตให้ดำเนินการต่อได้ ซึ่งมีประโยชน์เมื่อค่าถูกต้องตามเทคนิคแต่ไม่น่าจะเป็นทางสถิติ

รูปแบบทั่วไปคือใช้ note กับนิพจน์ relevant ที่แสดงค่าที่น่าสงสัย จับคู่กับคำถาม acknowledge เพื่อยืนยัน:

typenamelabelrelevant
integerchildrenNumber of children
notechildren_warningWarning: You entered ${children} children. Please confirm this is correct.. > 15
triggerchildren_confirmConfirm the number of children is correct${children} > 15
หน้านี้มีประโยชน์หรือไม่?