re: Use opaque types in Elm! VIEW POST

TOP OF THREAD FULL DISCUSSION
re: How about to hide 'validation' behind the 'create' method? What do you think about it?
 

Then the create function does multiple things. Not desirable. For instance, how would you show validation errors without submitting the form?

 

Then the create function does multiple things

For instance we have function which get 2 numbers and return sum of them. The first number is odd and the second is even.

function oddEvenSumm(odd, even) {
  if (even % 2 == 1) {
    throw new Error('not even one')
  }
  if (odd % 2 == 0) {
    throw new Error('not odd one')
  }

  return odd + even;
}

Should we create new types for these values (like you did for title and body) because we validate them?
Do we break Single Responsobiliy Principal?
Does it make sence to create separate type if we don't use them in other places?

code of conduct - report abuse