ml-archive / forms

Tools for working with Forms in Vapor
MIT License
7 stars 0 forks source link

Consider improving naming for validation modes #17

Open siemensikkema opened 6 years ago

siemensikkema commented 6 years ago

I'm not really a fan of the current validation modes names:

form.makeFieldset(inValidationMode: .all)
form.makeFieldset(inValidationMode: .none)
form.makeFieldset(inValidationMode: .nonNil)

(The same holds for the validate method.)

One alternative could be to remove the argument label:

form.makeFieldset(.all)
form.makeFieldset(.none)
form.makeFieldset(.nonNil)

or be a bit more explicit:

form.makeFieldset(validating: .allFields)
form.makeFieldset(validating: .noFields)
form.makeFieldset(validating: .onlyNonNilFields)

or change the names in such a way that they describe the typical use cases:

form.makeFieldset(.forNewEntity)
form.makeFieldset(.noEmptyEntity)
form.makeFieldset(.forUpdatedEntity)

@steffendsommer @BrettRToomey @MartinLasek what do you think?

steffendsommer commented 6 years ago

I think this reads quite well:

form.makeFieldset(validating: .allFields)
form.makeFieldset(validating: .noFields)
form.makeFieldset(validating: .onlyNonNilFields)