Skip to content
New issue

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

Property formatters, constraints #128

Closed
fabien opened this issue May 29, 2014 · 9 comments
Closed

Property formatters, constraints #128

fabien opened this issue May 29, 2014 · 9 comments

Comments

@fabien
Copy link
Contributor

fabien commented May 29, 2014

Where does the actual implementation of property formatters (trim, uppercase, ...) come from? Is it provided by a connector (or a database engine itself)? I could not find any references in-code, and it'd be interesting to be able to provide your own formatters (like urlify/slugify for example).

@fabien
Copy link
Contributor Author

fabien commented Jun 26, 2014

@bajtos @ritch @raymondfeng I believe that the docs are incorrect, as I cannot find any references in the source code (of datasource-juggler and loopback itself) regarding:

pattern, min/max, length, trim, lowercase, uppercase, format

I would have expected the constraints to add the right validations. Additionally, you'd expect a property with type=number to apply validatesNumericalityOf and so forth.

Constraints

Constraints are modeled as options too, for example:

  • default: The default value of the property
  • required: Indicate if the property is required
  • pattern: A regular expression pattern that a string should match
  • min/max: The minimal and maximal value
  • length: The maximal length of a string

Conversion and formatting

Format conversions can also be declared as options, for example:

  • trim: Trim the string
  • lowercase: Convert the string to be lowercase
  • uppercase: Convert the string to be uppercase
  • format: Format a Date

@fabien fabien changed the title Property formatters Property formatters, constraints Jun 26, 2014
@raymondfeng
Copy link
Contributor

We need to enhance the property handling to support the attributes for constraints and conversions.

@Klowner
Copy link

Klowner commented Apr 8, 2015

👍

@nathanmarks
Copy link

@raymondfeng Seems like this has been open a while -- shouldn't this be removed from the documentation in loopback? It caused me a lot of grief yesterday

@BerkeleyTrue
Copy link
Contributor

@raymondfeng This should definitely be remove from docs.

@crandmck
Copy link
Contributor

crandmck commented Aug 6, 2015

I "commented out" that section from http://docs.strongloop.com/display/LB/Model+definition+JSON+file, so it won't be visible to general viewers. Sorry it caused problems. Please mention or comment on strongloop/loopback#523 when this issue is fixed so I add the docs back once it actually works.

@leventgunay
Copy link

hello from the other side!! this feature would be really helpful, i guess. looking forward to your updates. thanks.

@stale
Copy link

stale bot commented Aug 23, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot closed this as completed Sep 6, 2017
@stale
Copy link

stale bot commented Sep 6, 2017

This issue has been closed due to continued inactivity. Thank you for your understanding. If you believe this to be in error, please contact one of the code owners, listed in the CODEOWNERS file at the top-level of this repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests