this repo has no description
4
fork

Configure Feed

Select the types of activity you want to include in your feed.

add boolean field

+34 -3
+5
forma/src/forma/field.gleam
··· 22 22 Field(input.empty_field(widget), 0.0, transform) 23 23 } 24 24 25 + pub fn boolean_field(widget: fn(Input(format)) -> format) -> Field(format, Bool) { 26 + let transform = validation.boolean 27 + Field(input.empty_field(widget), False, transform) 28 + } 29 + 25 30 pub type Field(format, output) { 26 31 Field( 27 32 input: Input(format),
+2
forma/src/forma/forma_pipes/forma.gleam
··· 5 5 // TODO 6 6 // - list fields 7 7 // - form sets 8 + // - decoders/toy.decoder 8 9 // - csrf token 10 + // - overwrite error messages 9 11 10 12 import forma/field.{type Field} 11 13 import forma/input.{type Input, Input}
+7 -3
forma/src/forma/string_fields.gleam
··· 1 1 import forma/field 2 2 import forma/input.{type Input} 3 3 4 - pub fn checkbox_widget(_f, _env) -> String { 4 + pub fn checkbox_widget(_f) -> String { 5 5 "<input type=\"checkbox\">" 6 6 } 7 7 8 - pub fn password_widget(_f, _env) -> String { 8 + pub fn password_widget(_f) -> String { 9 9 "<input type=\"password\">" 10 10 } 11 11 ··· 21 21 <> "\">" 22 22 } 23 23 24 - pub fn textarea_widget(_f, _env) -> String { 24 + pub fn textarea_widget(_f) -> String { 25 25 // https://chriscoyier.net/2023/09/29/css-solves-auto-expanding-textareas-probably-eventually/ 26 26 // https://til.simonwillison.net/css/resizing-textarea 27 27 "<textarea></textarea>" ··· 42 42 pub fn number_field() { 43 43 field.number_field(text_widget) 44 44 } 45 + 46 + pub fn boolean_field() { 47 + field.boolean_field(checkbox_widget) 48 + }
+20
forma/src/forma/validation.gleam
··· 44 44 |> result.replace_error("Must be a number") 45 45 } 46 46 47 + pub fn boolean(str: String) -> Result(Bool, String) { 48 + // https://github.com/hayleigh-dot-dev/decipher/blob/v1.2.1/src/decipher.gleam#L115-L115 49 + case string.trim(str) { 50 + "true" -> Ok(True) 51 + "True" -> Ok(True) 52 + "on" -> Ok(True) 53 + "On" -> Ok(True) 54 + "yes" -> Ok(True) 55 + "Yes" -> Ok(True) 56 + "false" -> Ok(False) 57 + "False" -> Ok(False) 58 + "off" -> Ok(False) 59 + "Off" -> Ok(False) 60 + "no" -> Ok(False) 61 + "No" -> Ok(False) 62 + "" -> Ok(False) 63 + _ -> Error("Must be true or false") 64 + } 65 + } 66 + 47 67 pub fn and( 48 68 previous: fn(a) -> Result(b, String), 49 69 next: fn(b) -> Result(c, String),