Skip to content

Releases: muonsoft/validation

v0.17.0

11 Mar 09:06
59a89fe
Compare
Choose a tag to compare

What's Changed

Full Changelog: v0.16.0...v0.17.0

v0.16.0

26 Oct 18:24
Compare
Choose a tag to compare
  • BC break stored constraints removed
  • BC break ip testing function signature updated to return error instead of bool
  • Instance() function in validator package

Full Changelog: v0.15.0...v0.16.0

v0.15.0

31 Jul 18:55
Compare
Choose a tag to compare
  • validation.ValidatableFunc added as a functional adapter for validation.Validatable interface
  • validation.BuiltinViolationFactory is now exported and can be reused
  • few code examples added for some complex cases

v0.14.0

17 Jul 19:18
05cfc84
Compare
Choose a tag to compare
  • Feature: it.DateTimeConstraint to validate date time values
  • Feature: marshal complex property path values into string
  • Feature: property path unmarshaling from string
  • Feature: new methods for validation.PropertyPath:
    • method Elements() returns property path as slice of PropertyPathElement
    • method Len() returns length of the property path
  • Feature: additional checks for it.URLConstraint:
    • WithHosts to check list of allowed hosts
    • WithHostMatches to check host by regexp pattern
    • WithRestriction to check by closure
  • breaking changes in packages is and validate:
    • validate.URL(value string, schemas ...string) error signature replaced by validate.URL(value string, restrictions ...URLRestriction) error
    • is.URL(value string, schemas ...string) error signature replaced by is.URL(value string, restrictions ...URLRestriction) error

v0.13.2

16 Jul 05:17
Compare
Choose a tag to compare

fix: revert behaviour for it.ChoiceConstraint (method WithAllowedBlank replaced by WithoutBlank)

v0.13.1

14 Jul 19:59
419bb42
Compare
Choose a tag to compare
  • violations formatting updated
  • more detailed assertion errors for violation assertions

v0.13.0

10 Jul 17:35
03ceef9
Compare
Choose a tag to compare
  • big refactoring with breaking changes
  • validation codes replaced by static errors
    • validation.Error added with constructor validation.NewError()
    • Violation.Code() string replaced by Violation.Unwrap() error method
    • package code removed
    • all Violation implementations can now be tested by standard errors.Is() function for containing static errors
  • most of constraint method names now are suffixed with With
  • it.IsEqualToString, it.IsNotEqualToString, it.IsEqualToNumber, it.IsNotEqualToNumber removed
  • validation.ViolationList.Each() renamed to validation.ViolationList.ForEach()
  • validation.ViolationList.Has() replaced by validation.ViolationList.Is()
  • signatures for all constraints updated from Validate<Type>(value, scope) to Validate<Type>(ctx, validator, value)
  • validation.Scope removed (all exported methods moved to validation.Validator)
  • validation.NewTypedArgument() renamed to validation.This()
  • validation.CustomStringConstraint renamed to validation.StringFuncConstraint
  • validation.NewCustomStringConstraint() renamed to validation.OfStringBy()
  • validation.Language argument removed
  • validation.Option and all implementations removed
  • argument With with Option method replaced by At method with property path
  • validation.PropertyNameElement renamed to validation.PropertyName
  • validation.ArrayIndexElement renamed to validation.ArrayIndex
  • it.NotBlankConstraint.AllowNil() renamed to it.NotBlankConstraint.WithAllowedNil()
  • it.ChoiceConstraint blank value behaviour updated (additional method WithAllowedBlank() added)
  • all previous deprecations removed

See all updates in pull request #74

v0.12.0

22 Jun 18:01
Compare
Choose a tag to compare
  • Feature: Generic Constraint interface and NewTypedArgument constructor.
  • Feature: AllArgument for composing a complex validation.
  • Feature: AsyncArgument for asynchronous validation.
  • Fixed: All error methods now have pointer receivers.

v0.11.0

21 Apr 18:31
b26c626
Compare
Choose a tag to compare
  • ViolationListBuilder added to build violation lists. Can be initiated by scope.BuildViolationList() or validation.BuildViolationList() methods.
  • New methods for ViolationBuilder and renaming (some methods are deprecated).
  • scope.CreateViolation() and validator.CreateViolation() methods added.
  • scope.Validate() method is now exported.

v0.10.0

17 Apr 08:31
aafecfa
Compare
Choose a tag to compare
  • it.NotBlankConstraint, it.BlankConstraint, it.NilConstraint and it.NotNilConstraint now are based on generic comparable type and can be used as NumberConstraint and ComparableConstraint:
    • it.NotBlankNumberConstraint and it.BlankNumberConstraint are removed;
    • it.IsNotBlankNumber() and it.IsBlankNumber() now returns it.NotBlankConstraint and it.BlankConstraint;
    • new constructors were added.
  • it.ChoiceConstraint now is compatible with NumberConstraint and StringConstraint.
  • New generic it.ComparisonConstraint added to compare comparable types. Use it with constructors it.IsEqualTo() and it.IsNotEqualTo().
  • it.IsEqualToString(), it.IsNotEqualToString(), it.IsEqualToNumber() and it.IsNotEqualToNumber() marked as deprecated.
  • More runnable examples and docs.