elm-pages 3.0.0-beta.8 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -2
- package/adapter/netlify.js +207 -0
- package/codegen/{elm-pages-codegen.js → elm-pages-codegen.cjs} +2730 -2938
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmi +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateData.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-DeadCodeEliminateDataTest.elmo +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1527 -422
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/Runner.elm.js +16840 -13653
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/dead-code-review/elm-stuff/tests-0.19.1/js/node_supervisor.js +2 -2
- package/generator/dead-code-review/elm.json +9 -7
- package/generator/dead-code-review/src/Pages/Review/DeadCodeEliminateData.elm +59 -10
- package/generator/dead-code-review/tests/Pages/Review/DeadCodeEliminateDataTest.elm +52 -36
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Internal-RoutePattern.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmi +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/Pages-Review-NoContractViolations.elmo +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/d.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/i.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm-stuff/0.19.1/o.dat +0 -0
- package/generator/review/elm-stuff/tests-0.19.1/elm.json +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/Reporter.elm.js +1527 -422
- package/generator/review/elm-stuff/tests-0.19.1/js/Runner.elm.js +25118 -21832
- package/generator/review/elm-stuff/tests-0.19.1/js/node_runner.js +1 -1
- package/generator/review/elm-stuff/tests-0.19.1/js/node_supervisor.js +2 -2
- package/generator/review/elm.json +10 -10
- package/generator/src/RouteBuilder.elm +93 -128
- package/generator/src/SharedTemplate.elm +8 -7
- package/generator/src/SiteConfig.elm +3 -2
- package/generator/src/basepath-middleware.js +3 -3
- package/generator/src/build.js +147 -63
- package/generator/src/cli.js +292 -88
- package/generator/src/codegen.js +29 -27
- package/generator/src/compatibility-key.js +3 -0
- package/generator/src/compile-elm.js +43 -26
- package/generator/src/config.js +2 -4
- package/generator/src/copy-dir.js +2 -2
- package/generator/src/dev-server.js +159 -92
- package/generator/src/dir-helpers.js +9 -26
- package/generator/src/elm-codegen.js +5 -4
- package/generator/src/elm-file-constants.js +2 -3
- package/generator/src/error-formatter.js +12 -11
- package/generator/src/file-helpers.js +3 -4
- package/generator/src/generate-template-module-connector.js +23 -23
- package/generator/src/init.js +9 -8
- package/generator/src/pre-render-html.js +10 -13
- package/generator/src/render-test.js +109 -0
- package/generator/src/render-worker.js +25 -28
- package/generator/src/render.js +321 -142
- package/generator/src/request-cache.js +265 -162
- package/generator/src/resolve-elm-module.js +64 -0
- package/generator/src/rewrite-client-elm-json.js +6 -5
- package/generator/src/rewrite-elm-json-help.js +56 -0
- package/generator/src/rewrite-elm-json.js +17 -7
- package/generator/src/route-codegen-helpers.js +16 -31
- package/generator/src/seo-renderer.js +12 -7
- package/generator/src/vite-utils.js +1 -2
- package/generator/static-code/elm-pages.js +10 -0
- package/generator/static-code/hmr.js +79 -13
- package/generator/template/app/Api.elm +3 -2
- package/generator/template/app/Effect.elm +155 -0
- package/generator/template/app/ErrorPage.elm +49 -6
- package/generator/template/app/Route/Blog/Slug_.elm +86 -0
- package/generator/template/app/Route/Greet.elm +107 -0
- package/generator/template/app/Route/Hello.elm +119 -0
- package/generator/template/app/Route/Index.elm +26 -25
- package/generator/template/app/Shared.elm +38 -39
- package/generator/template/app/Site.elm +4 -7
- package/generator/template/app/View.elm +9 -8
- package/generator/template/codegen/elm.codegen.json +18 -0
- package/generator/template/custom-backend-task.ts +3 -0
- package/generator/template/elm-pages.config.mjs +13 -0
- package/generator/template/elm-tooling.json +0 -3
- package/generator/template/elm.json +25 -20
- package/generator/template/index.ts +1 -2
- package/generator/template/netlify.toml +4 -1
- package/generator/template/package.json +10 -4
- package/generator/template/script/.elm-pages/compiled-ports/custom-backend-task.mjs +7 -0
- package/generator/template/script/custom-backend-task.ts +3 -0
- package/generator/template/script/elm.json +61 -0
- package/generator/template/script/src/AddRoute.elm +312 -0
- package/generator/template/script/src/Stars.elm +42 -0
- package/package.json +30 -27
- package/src/ApiRoute.elm +249 -85
- package/src/BackendTask/Custom.elm +325 -0
- package/src/BackendTask/Env.elm +90 -0
- package/src/{DataSource → BackendTask}/File.elm +171 -56
- package/src/{DataSource → BackendTask}/Glob.elm +136 -125
- package/src/BackendTask/Http.elm +679 -0
- package/src/{DataSource → BackendTask}/Internal/Glob.elm +1 -1
- package/src/BackendTask/Internal/Request.elm +69 -0
- package/src/BackendTask/Random.elm +79 -0
- package/src/BackendTask/Time.elm +47 -0
- package/src/BackendTask.elm +531 -0
- package/src/FatalError.elm +90 -0
- package/src/FormData.elm +21 -18
- package/src/Head/Seo.elm +4 -4
- package/src/Head.elm +237 -7
- package/src/Internal/ApiRoute.elm +7 -5
- package/src/Internal/Request.elm +84 -4
- package/src/PageServerResponse.elm +6 -1
- package/src/Pages/ConcurrentSubmission.elm +127 -0
- package/src/Pages/Form.elm +340 -0
- package/src/Pages/FormData.elm +19 -0
- package/src/Pages/GeneratorProgramConfig.elm +15 -0
- package/src/Pages/Internal/FatalError.elm +5 -0
- package/src/Pages/Internal/Msg.elm +93 -0
- package/src/Pages/Internal/NotFoundReason.elm +4 -4
- package/src/Pages/Internal/Platform/Cli.elm +629 -767
- package/src/Pages/Internal/Platform/CompatibilityKey.elm +6 -0
- package/src/Pages/Internal/Platform/Effect.elm +1 -2
- package/src/Pages/Internal/Platform/GeneratorApplication.elm +379 -0
- package/src/Pages/Internal/Platform/StaticResponses.elm +65 -276
- package/src/Pages/Internal/Platform/ToJsPayload.elm +6 -9
- package/src/Pages/Internal/Platform.elm +330 -203
- package/src/Pages/Internal/ResponseSketch.elm +2 -2
- package/src/Pages/Internal/Script.elm +17 -0
- package/src/Pages/Internal/StaticHttpBody.elm +35 -1
- package/src/Pages/Manifest.elm +52 -11
- package/src/Pages/Navigation.elm +85 -0
- package/src/Pages/PageUrl.elm +26 -12
- package/src/Pages/ProgramConfig.elm +32 -22
- package/src/Pages/Script.elm +166 -0
- package/src/Pages/SiteConfig.elm +3 -2
- package/src/Pages/StaticHttp/Request.elm +2 -2
- package/src/Pages/StaticHttpRequest.elm +23 -99
- package/src/Pages/Url.elm +3 -3
- package/src/PagesMsg.elm +88 -0
- package/src/QueryParams.elm +21 -172
- package/src/RenderRequest.elm +7 -7
- package/src/RequestsAndPending.elm +37 -20
- package/src/Result/Extra.elm +26 -0
- package/src/Scaffold/Form.elm +569 -0
- package/src/Scaffold/Route.elm +1431 -0
- package/src/Server/Request.elm +476 -1001
- package/src/Server/Response.elm +130 -36
- package/src/Server/Session.elm +181 -111
- package/src/Server/SetCookie.elm +80 -32
- package/src/Stub.elm +53 -0
- package/src/Test/Html/Internal/ElmHtml/ToString.elm +8 -9
- package/src/{Path.elm → UrlPath.elm} +33 -36
- package/generator/template/public/images/icon-png.png +0 -0
- package/src/DataSource/Env.elm +0 -38
- package/src/DataSource/Http.elm +0 -446
- package/src/DataSource/Internal/Request.elm +0 -20
- package/src/DataSource/Port.elm +0 -90
- package/src/DataSource.elm +0 -538
- package/src/Form/Field.elm +0 -717
- package/src/Form/FieldStatus.elm +0 -36
- package/src/Form/FieldView.elm +0 -417
- package/src/Form/FormData.elm +0 -22
- package/src/Form/Validation.elm +0 -391
- package/src/Form/Value.elm +0 -118
- package/src/Form.elm +0 -1683
- package/src/FormDecoder.elm +0 -102
- package/src/Pages/FormState.elm +0 -256
- package/src/Pages/Generate.elm +0 -1151
- package/src/Pages/Internal/Form.elm +0 -17
- package/src/Pages/Msg.elm +0 -79
- package/src/Pages/Transition.elm +0 -70
package/src/Form/Validation.elm
DELETED
|
@@ -1,391 +0,0 @@
|
|
|
1
|
-
module Form.Validation exposing
|
|
2
|
-
( Combined, Field, Validation
|
|
3
|
-
, andMap, andThen, fail, fromMaybe, fromResult, map, map2, parseWithError, succeed, succeed2, withError, withErrorIf, withFallback
|
|
4
|
-
, value, fieldName, fieldStatus
|
|
5
|
-
, map3, map4, map5, map6, map7, map8, map9
|
|
6
|
-
, global
|
|
7
|
-
, mapWithNever
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
{-|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
## Validations
|
|
14
|
-
|
|
15
|
-
@docs Combined, Field, Validation
|
|
16
|
-
|
|
17
|
-
@docs andMap, andThen, fail, fromMaybe, fromResult, map, map2, parseWithError, succeed, succeed2, withError, withErrorIf, withFallback
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
## Field Metadata
|
|
21
|
-
|
|
22
|
-
@docs value, fieldName, fieldStatus
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
## Mapping
|
|
26
|
-
|
|
27
|
-
@docs map3, map4, map5, map6, map7, map8, map9
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
## Global Validation
|
|
31
|
-
|
|
32
|
-
@docs global
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
## Temporary?
|
|
36
|
-
|
|
37
|
-
@docs mapWithNever
|
|
38
|
-
|
|
39
|
-
-}
|
|
40
|
-
|
|
41
|
-
import Dict exposing (Dict)
|
|
42
|
-
import Form.FieldStatus exposing (FieldStatus)
|
|
43
|
-
import Pages.Internal.Form exposing (ViewField)
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
{-| -}
|
|
47
|
-
type alias Combined error parsed =
|
|
48
|
-
Validation error parsed Never Never
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{-| -}
|
|
52
|
-
type alias Field error parsed kind =
|
|
53
|
-
Validation error parsed kind { field : kind }
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{-| -}
|
|
57
|
-
type alias Validation error parsed kind constraints =
|
|
58
|
-
Pages.Internal.Form.Validation error parsed kind constraints
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
{-| -}
|
|
62
|
-
fieldName : Field error parsed kind -> String
|
|
63
|
-
fieldName (Pages.Internal.Form.Validation _ name _) =
|
|
64
|
-
name
|
|
65
|
-
|> Maybe.withDefault ""
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
{-| -}
|
|
69
|
-
fieldStatus : Field error parsed kind -> FieldStatus
|
|
70
|
-
fieldStatus (Pages.Internal.Form.Validation viewField _ _) =
|
|
71
|
-
viewField
|
|
72
|
-
|> expectViewField
|
|
73
|
-
|> .status
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
expectViewField : Maybe (ViewField kind) -> ViewField kind
|
|
77
|
-
expectViewField viewField =
|
|
78
|
-
case viewField of
|
|
79
|
-
Just justViewField ->
|
|
80
|
-
justViewField
|
|
81
|
-
|
|
82
|
-
Nothing ->
|
|
83
|
-
expectViewField viewField
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{-| -}
|
|
87
|
-
succeed : parsed -> Combined error parsed
|
|
88
|
-
succeed parsed =
|
|
89
|
-
Pages.Internal.Form.Validation Nothing Nothing ( Just parsed, Dict.empty )
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
{-| -}
|
|
93
|
-
succeed2 : parsed -> Validation error parsed kind constraints
|
|
94
|
-
succeed2 parsed =
|
|
95
|
-
Pages.Internal.Form.Validation Nothing Nothing ( Just parsed, Dict.empty )
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
{-| -}
|
|
99
|
-
global : Field error () Never
|
|
100
|
-
global =
|
|
101
|
-
Pages.Internal.Form.Validation Nothing
|
|
102
|
-
(Just "$$global$$")
|
|
103
|
-
( Just ()
|
|
104
|
-
, Dict.empty
|
|
105
|
-
)
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
{-| -}
|
|
109
|
-
withFallback : parsed -> Validation error parsed named constraints -> Validation error parsed named constraints
|
|
110
|
-
withFallback parsed (Pages.Internal.Form.Validation viewField name ( maybeParsed, errors )) =
|
|
111
|
-
Pages.Internal.Form.Validation viewField
|
|
112
|
-
name
|
|
113
|
-
( maybeParsed
|
|
114
|
-
|> Maybe.withDefault parsed
|
|
115
|
-
|> Just
|
|
116
|
-
, errors
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
{-| -}
|
|
121
|
-
value : Validation error parsed named constraint -> Maybe parsed
|
|
122
|
-
value (Pages.Internal.Form.Validation _ _ ( maybeParsed, _ )) =
|
|
123
|
-
maybeParsed
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
{-| -}
|
|
127
|
-
parseWithError : parsed -> ( String, error ) -> Combined error parsed
|
|
128
|
-
parseWithError parsed ( key, error ) =
|
|
129
|
-
Pages.Internal.Form.Validation Nothing Nothing ( Just parsed, Dict.singleton key [ error ] )
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
{-| -}
|
|
133
|
-
fail : error -> Field error parsed1 field -> Combined error parsed
|
|
134
|
-
fail parsed (Pages.Internal.Form.Validation _ key _) =
|
|
135
|
-
Pages.Internal.Form.Validation Nothing Nothing ( Nothing, Dict.singleton (key |> Maybe.withDefault "") [ parsed ] )
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
{-| -}
|
|
139
|
-
withError : Field error parsed1 field -> error -> Validation error parsed2 named constraints -> Validation error parsed2 named constraints
|
|
140
|
-
withError (Pages.Internal.Form.Validation _ key _) error (Pages.Internal.Form.Validation viewField name ( maybeParsedA, errorsA )) =
|
|
141
|
-
Pages.Internal.Form.Validation viewField name ( maybeParsedA, errorsA |> insertIfNonempty (key |> Maybe.withDefault "") [ error ] )
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
{-| -}
|
|
145
|
-
withErrorIf : Bool -> Field error ignored field -> error -> Validation error parsed named constraints -> Validation error parsed named constraints
|
|
146
|
-
withErrorIf includeError (Pages.Internal.Form.Validation _ key _) error (Pages.Internal.Form.Validation viewField name ( maybeParsedA, errorsA )) =
|
|
147
|
-
Pages.Internal.Form.Validation viewField
|
|
148
|
-
name
|
|
149
|
-
( maybeParsedA
|
|
150
|
-
, if includeError then
|
|
151
|
-
errorsA |> insertIfNonempty (key |> Maybe.withDefault "") [ error ]
|
|
152
|
-
|
|
153
|
-
else
|
|
154
|
-
errorsA
|
|
155
|
-
)
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
--map : (parsed -> mapped) -> Validation error parsed named -> Validation error mapped named
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
{-| -}
|
|
163
|
-
map : (parsed -> mapped) -> Validation error parsed named constraint -> Validation error mapped named constraint
|
|
164
|
-
map mapFn (Pages.Internal.Form.Validation _ name ( maybeParsedA, errorsA )) =
|
|
165
|
-
Pages.Internal.Form.Validation Nothing name ( Maybe.map mapFn maybeParsedA, errorsA )
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
{-| -}
|
|
169
|
-
mapWithNever : (parsed -> mapped) -> Validation error parsed named constraint -> Validation error mapped Never Never
|
|
170
|
-
mapWithNever mapFn (Pages.Internal.Form.Validation _ name ( maybeParsedA, errorsA )) =
|
|
171
|
-
Pages.Internal.Form.Validation Nothing name ( Maybe.map mapFn maybeParsedA, errorsA )
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
{-| -}
|
|
175
|
-
fromResult : Field error (Result error parsed) kind -> Combined error parsed
|
|
176
|
-
fromResult fieldResult =
|
|
177
|
-
fieldResult
|
|
178
|
-
|> andThen
|
|
179
|
-
(\parsedValue ->
|
|
180
|
-
case parsedValue of
|
|
181
|
-
Ok okValue ->
|
|
182
|
-
succeed okValue
|
|
183
|
-
|
|
184
|
-
Err error ->
|
|
185
|
-
fail error fieldResult
|
|
186
|
-
)
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
{-| -}
|
|
190
|
-
andMap : Validation error a named1 constraints1 -> Validation error (a -> b) named2 constraints2 -> Combined error b
|
|
191
|
-
andMap =
|
|
192
|
-
map2 (|>)
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
{-| -}
|
|
196
|
-
andThen : (parsed -> Validation error mapped named1 constraints1) -> Validation error parsed named2 constraints2 -> Combined error mapped
|
|
197
|
-
andThen andThenFn (Pages.Internal.Form.Validation _ _ ( maybeParsed, errors )) =
|
|
198
|
-
case maybeParsed of
|
|
199
|
-
Just parsed ->
|
|
200
|
-
andThenFn parsed
|
|
201
|
-
|> (\(Pages.Internal.Form.Validation _ _ ( andThenParsed, andThenErrors )) ->
|
|
202
|
-
Pages.Internal.Form.Validation Nothing Nothing ( andThenParsed, mergeErrors errors andThenErrors )
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
Nothing ->
|
|
206
|
-
Pages.Internal.Form.Validation Nothing Nothing ( Nothing, errors )
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
{-| -}
|
|
210
|
-
map2 : (a -> b -> c) -> Validation error a named1 constraints1 -> Validation error b named2 constraints2 -> Combined error c
|
|
211
|
-
map2 f (Pages.Internal.Form.Validation _ _ ( maybeParsedA, errorsA )) (Pages.Internal.Form.Validation _ _ ( maybeParsedB, errorsB )) =
|
|
212
|
-
Pages.Internal.Form.Validation Nothing
|
|
213
|
-
Nothing
|
|
214
|
-
( Maybe.map2 f maybeParsedA maybeParsedB
|
|
215
|
-
, mergeErrors errorsA errorsB
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
{-| -}
|
|
220
|
-
map3 :
|
|
221
|
-
(a1 -> a2 -> a3 -> a4)
|
|
222
|
-
-> Validation error a1 named1 constraints1
|
|
223
|
-
-> Validation error a2 named2 constraints2
|
|
224
|
-
-> Validation error a3 named3 constraints3
|
|
225
|
-
-> Combined error a4
|
|
226
|
-
map3 f validation1 validation2 validation3 =
|
|
227
|
-
succeed f
|
|
228
|
-
|> andMap validation1
|
|
229
|
-
|> andMap validation2
|
|
230
|
-
|> andMap validation3
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
{-| -}
|
|
234
|
-
map4 :
|
|
235
|
-
(a1 -> a2 -> a3 -> a4 -> a5)
|
|
236
|
-
-> Validation error a1 named1 constraints1
|
|
237
|
-
-> Validation error a2 named2 constraints2
|
|
238
|
-
-> Validation error a3 named3 constraints3
|
|
239
|
-
-> Validation error a4 named4 constraints4
|
|
240
|
-
-> Combined error a5
|
|
241
|
-
map4 f validation1 validation2 validation3 validation4 =
|
|
242
|
-
succeed f
|
|
243
|
-
|> andMap validation1
|
|
244
|
-
|> andMap validation2
|
|
245
|
-
|> andMap validation3
|
|
246
|
-
|> andMap validation4
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
{-| -}
|
|
250
|
-
map5 :
|
|
251
|
-
(a1 -> a2 -> a3 -> a4 -> a5 -> a6)
|
|
252
|
-
-> Validation error a1 named1 constraints1
|
|
253
|
-
-> Validation error a2 named2 constraints2
|
|
254
|
-
-> Validation error a3 named3 constraints3
|
|
255
|
-
-> Validation error a4 named4 constraints4
|
|
256
|
-
-> Validation error a5 named5 constraints5
|
|
257
|
-
-> Combined error a6
|
|
258
|
-
map5 f validation1 validation2 validation3 validation4 validation5 =
|
|
259
|
-
succeed f
|
|
260
|
-
|> andMap validation1
|
|
261
|
-
|> andMap validation2
|
|
262
|
-
|> andMap validation3
|
|
263
|
-
|> andMap validation4
|
|
264
|
-
|> andMap validation5
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
{-| -}
|
|
268
|
-
map6 :
|
|
269
|
-
(a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7)
|
|
270
|
-
-> Validation error a1 named1 constraints1
|
|
271
|
-
-> Validation error a2 named2 constraints2
|
|
272
|
-
-> Validation error a3 named3 constraints3
|
|
273
|
-
-> Validation error a4 named4 constraints4
|
|
274
|
-
-> Validation error a5 named5 constraints5
|
|
275
|
-
-> Validation error a6 named6 constraints6
|
|
276
|
-
-> Combined error a7
|
|
277
|
-
map6 f validation1 validation2 validation3 validation4 validation5 validation6 =
|
|
278
|
-
succeed f
|
|
279
|
-
|> andMap validation1
|
|
280
|
-
|> andMap validation2
|
|
281
|
-
|> andMap validation3
|
|
282
|
-
|> andMap validation4
|
|
283
|
-
|> andMap validation5
|
|
284
|
-
|> andMap validation6
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
{-| -}
|
|
288
|
-
map7 :
|
|
289
|
-
(a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8)
|
|
290
|
-
-> Validation error a1 named1 constraints1
|
|
291
|
-
-> Validation error a2 named2 constraints2
|
|
292
|
-
-> Validation error a3 named3 constraints3
|
|
293
|
-
-> Validation error a4 named4 constraints4
|
|
294
|
-
-> Validation error a5 named5 constraints5
|
|
295
|
-
-> Validation error a6 named6 constraints6
|
|
296
|
-
-> Validation error a7 named7 constraints7
|
|
297
|
-
-> Combined error a8
|
|
298
|
-
map7 f validation1 validation2 validation3 validation4 validation5 validation6 validation7 =
|
|
299
|
-
succeed f
|
|
300
|
-
|> andMap validation1
|
|
301
|
-
|> andMap validation2
|
|
302
|
-
|> andMap validation3
|
|
303
|
-
|> andMap validation4
|
|
304
|
-
|> andMap validation5
|
|
305
|
-
|> andMap validation6
|
|
306
|
-
|> andMap validation7
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
{-| -}
|
|
310
|
-
map8 :
|
|
311
|
-
(a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9)
|
|
312
|
-
-> Validation error a1 named1 constraints1
|
|
313
|
-
-> Validation error a2 named2 constraints2
|
|
314
|
-
-> Validation error a3 named3 constraints3
|
|
315
|
-
-> Validation error a4 named4 constraints4
|
|
316
|
-
-> Validation error a5 named5 constraints5
|
|
317
|
-
-> Validation error a6 named6 constraints6
|
|
318
|
-
-> Validation error a7 named7 constraints7
|
|
319
|
-
-> Validation error a8 named8 constraints8
|
|
320
|
-
-> Combined error a9
|
|
321
|
-
map8 f validation1 validation2 validation3 validation4 validation5 validation6 validation7 validation8 =
|
|
322
|
-
succeed f
|
|
323
|
-
|> andMap validation1
|
|
324
|
-
|> andMap validation2
|
|
325
|
-
|> andMap validation3
|
|
326
|
-
|> andMap validation4
|
|
327
|
-
|> andMap validation5
|
|
328
|
-
|> andMap validation6
|
|
329
|
-
|> andMap validation7
|
|
330
|
-
|> andMap validation8
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
{-| -}
|
|
334
|
-
map9 :
|
|
335
|
-
(a1 -> a2 -> a3 -> a4 -> a5 -> a6 -> a7 -> a8 -> a9 -> a10)
|
|
336
|
-
-> Validation error a1 named1 constraints1
|
|
337
|
-
-> Validation error a2 named2 constraints2
|
|
338
|
-
-> Validation error a3 named3 constraints3
|
|
339
|
-
-> Validation error a4 named4 constraints4
|
|
340
|
-
-> Validation error a5 named5 constraints5
|
|
341
|
-
-> Validation error a6 named6 constraints6
|
|
342
|
-
-> Validation error a7 named7 constraints7
|
|
343
|
-
-> Validation error a8 named8 constraints8
|
|
344
|
-
-> Validation error a9 named9 constraints9
|
|
345
|
-
-> Combined error a10
|
|
346
|
-
map9 f validation1 validation2 validation3 validation4 validation5 validation6 validation7 validation8 validation9 =
|
|
347
|
-
succeed f
|
|
348
|
-
|> andMap validation1
|
|
349
|
-
|> andMap validation2
|
|
350
|
-
|> andMap validation3
|
|
351
|
-
|> andMap validation4
|
|
352
|
-
|> andMap validation5
|
|
353
|
-
|> andMap validation6
|
|
354
|
-
|> andMap validation7
|
|
355
|
-
|> andMap validation8
|
|
356
|
-
|> andMap validation9
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
{-| -}
|
|
360
|
-
fromMaybe : Maybe parsed -> Combined error parsed
|
|
361
|
-
fromMaybe maybe =
|
|
362
|
-
Pages.Internal.Form.Validation Nothing Nothing ( maybe, Dict.empty )
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
{-| -}
|
|
366
|
-
mergeErrors : Dict comparable (List value) -> Dict comparable (List value) -> Dict comparable (List value)
|
|
367
|
-
mergeErrors errors1 errors2 =
|
|
368
|
-
Dict.merge
|
|
369
|
-
(\key entries soFar ->
|
|
370
|
-
soFar |> insertIfNonempty key entries
|
|
371
|
-
)
|
|
372
|
-
(\key entries1 entries2 soFar ->
|
|
373
|
-
soFar |> insertIfNonempty key (entries1 ++ entries2)
|
|
374
|
-
)
|
|
375
|
-
(\key entries soFar ->
|
|
376
|
-
soFar |> insertIfNonempty key entries
|
|
377
|
-
)
|
|
378
|
-
errors1
|
|
379
|
-
errors2
|
|
380
|
-
Dict.empty
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
{-| -}
|
|
384
|
-
insertIfNonempty : comparable -> List value -> Dict comparable (List value) -> Dict comparable (List value)
|
|
385
|
-
insertIfNonempty key values dict =
|
|
386
|
-
if values |> List.isEmpty then
|
|
387
|
-
dict
|
|
388
|
-
|
|
389
|
-
else
|
|
390
|
-
dict
|
|
391
|
-
|> Dict.insert key values
|
package/src/Form/Value.elm
DELETED
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
module Form.Value exposing
|
|
2
|
-
( Value, date, float, int, string, bool, toString
|
|
3
|
-
, compare
|
|
4
|
-
)
|
|
5
|
-
|
|
6
|
-
{-|
|
|
7
|
-
|
|
8
|
-
@docs Value, date, float, int, string, bool, toString
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
## Comparison
|
|
12
|
-
|
|
13
|
-
@docs compare
|
|
14
|
-
|
|
15
|
-
-}
|
|
16
|
-
|
|
17
|
-
import Date exposing (Date)
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
type Kind
|
|
21
|
-
= StringValue
|
|
22
|
-
| DateValue
|
|
23
|
-
| IntValue
|
|
24
|
-
| FloatValue
|
|
25
|
-
| BoolValue
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
{-| -}
|
|
29
|
-
type Value dataType
|
|
30
|
-
= Value Kind String
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
{-| -}
|
|
34
|
-
toString : Value dataType -> String
|
|
35
|
-
toString (Value _ rawValue) =
|
|
36
|
-
rawValue
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
{-| -}
|
|
40
|
-
date : Date -> Value Date
|
|
41
|
-
date date_ =
|
|
42
|
-
date_
|
|
43
|
-
|> Date.toIsoString
|
|
44
|
-
|> Value DateValue
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
{-| -}
|
|
48
|
-
float : Float -> Value Float
|
|
49
|
-
float float_ =
|
|
50
|
-
float_
|
|
51
|
-
|> String.fromFloat
|
|
52
|
-
|> Value FloatValue
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
{-| -}
|
|
56
|
-
int : Int -> Value Int
|
|
57
|
-
int int_ =
|
|
58
|
-
int_
|
|
59
|
-
|> String.fromInt
|
|
60
|
-
|> Value IntValue
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
{-| -}
|
|
64
|
-
bool : Bool -> Value Bool
|
|
65
|
-
bool bool_ =
|
|
66
|
-
(case bool_ of
|
|
67
|
-
True ->
|
|
68
|
-
"on"
|
|
69
|
-
|
|
70
|
-
False ->
|
|
71
|
-
""
|
|
72
|
-
)
|
|
73
|
-
|> Value BoolValue
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
{-| -}
|
|
77
|
-
string : String -> Value String
|
|
78
|
-
string string_ =
|
|
79
|
-
string_
|
|
80
|
-
|> Value StringValue
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
{-| You probably don't need this helper as it's mostly useful for internal implementation.
|
|
84
|
-
-}
|
|
85
|
-
compare : String -> Value value -> Order
|
|
86
|
-
compare a (Value kind rawValue) =
|
|
87
|
-
case kind of
|
|
88
|
-
IntValue ->
|
|
89
|
-
case ( String.toInt a, String.toInt rawValue ) of
|
|
90
|
-
( Just parsedA, Just parsedB ) ->
|
|
91
|
-
Basics.compare parsedA parsedB
|
|
92
|
-
|
|
93
|
-
_ ->
|
|
94
|
-
LT
|
|
95
|
-
|
|
96
|
-
StringValue ->
|
|
97
|
-
-- the phantom types in the Field API don't ever run this, so it won't be called there
|
|
98
|
-
-- Just in case anyone calls it, it delegates to Basics.compare
|
|
99
|
-
Basics.compare a rawValue
|
|
100
|
-
|
|
101
|
-
BoolValue ->
|
|
102
|
-
-- the phantom types in the Field API don't ever run this, so it won't be called there
|
|
103
|
-
-- Just in case anyone calls it, it delegates to Basics.compare
|
|
104
|
-
Basics.compare a rawValue
|
|
105
|
-
|
|
106
|
-
DateValue ->
|
|
107
|
-
Result.map2 Date.compare
|
|
108
|
-
(Date.fromIsoString a)
|
|
109
|
-
(Date.fromIsoString rawValue)
|
|
110
|
-
|> Result.withDefault LT
|
|
111
|
-
|
|
112
|
-
FloatValue ->
|
|
113
|
-
case ( String.toFloat a, String.toFloat rawValue ) of
|
|
114
|
-
( Just parsedA, Just parsedB ) ->
|
|
115
|
-
Basics.compare parsedA parsedB
|
|
116
|
-
|
|
117
|
-
_ ->
|
|
118
|
-
LT
|