We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have some ideas to introduce validation capability to Resty.
The simplest idea is assert in the constructor of the case class:
assert
case class Message(message: String){ assert(message.nonEmpty, "message is empty.") }
Response would be:
{ "errors": [ "assertion failed: message is empty." ] }
Second idea is implementing validation logic as validation() method of the case class:
validation()
case class Message(message: String) extends ValidationSupport { override def validate(): Option[ErrorModel] = { if(message.isEmpty){ Some(ErrorModel(Seq(message is empty.))) } else { None } } }
Third idea is providing validation annotations for the case class:
case class Message( @NonEmpty @MaxLength(100) message: String )
BeanValidation might be another choise instead of original annotations.
The text was updated successfully, but these errors were encountered:
(refs #7)Responds AssertionError as BadRequest
1e47085
(refs #7)Remove prefix of the message of AssertionError
1bc3db0
Merge pull request #22 from takezoe/validation
8e566a4
(refs #7)Validation support for input parameters
No branches or pull requests
I have some ideas to introduce validation capability to Resty.
assert properties in the constructor
The simplest idea is
assert
in the constructor of the case class:Response would be:
validate method of the case class
Second idea is implementing validation logic as
validation()
method of the case class:annotation for the case class
Third idea is providing validation annotations for the case class:
BeanValidation might be another choise instead of original annotations.
The text was updated successfully, but these errors were encountered: