สวัสดี ฉันต้องการสร้างไฟล์ที่ยอมรับเฉพาะค่าที่มีอยู่ในตาราง (มีมากกว่า 20,000 แถว) ดังนั้นฉันจึงมีรหัสต่อไปนี้
demoForm :: Maybe Demo -> AForm Handler Demo
demoForm demo = Demo
<$> areq nitField (bfs (MsgName)) (demoFieldOne <$> demo)
<*> areq intField (bfs (MsgName)) (demoFieldTwo <$> demo)
where
errorMessage :: Text
errorMessage = "the company no exist!"
nitField = check validateNit textField
validateNit nit
| companiesMatch nit = Left errorMessage
| otherwise = Right nit
companiesMatch name = do
entities <- runDB $ selectList [CompanyName ==. name] []
return (null entities)
แต่ฉันได้รับข้อผิดพลาด Couldn't match expected type ‘Bool’with actual type ‘m0 (HandlerT site0 IO Bool)’
ดังนั้นจะรับค่าบูลจาก monad ได้อย่างไร หรือมีวิธีที่ดีกว่าในการตรวจสอบความถูกต้องนี้